Terraform:从快照创建 AWS Lightsail 实例

Terraform: Create AWS Lightsail instance from snapshot

鉴于 AWS Lightsail 上的 Terraform documentation,我可以构建一个全新的 Lightsail 实例,如下所示。

resource "aws_lightsail_instance" "my_ls_instance" {
  name              = "my_ls"
  availability_zone = "us-east-1b"
  blueprint_id      = "ubuntu_18_04"
  bundle_id         = "2xlarge_2_0"
  key_pair_name     = "MyKeyName"
}

可以使用 Terraform 从 Lightsail snapshot 创建 Lightsail 实例吗?

不,不是。目前 Terraform 只能创建基于 Lightsail 蓝图的实例。

但是,您可以从 python3 /w boto3 中的快照创建一个实例。让我包括我的代码:

#######

     import boto3
     client = boto3.client('lightsail')


     response = client.create_instances_from_snapshot(

     instanceNames=[
     'myitblog',
     ],

     availabilityZone='us-east-1a',
     instanceSnapshotName='MYITBLOG_https',
     bundleId='nano_2_0',



     )
     response = client.attach_static_ip(
     staticIpName='StaticIp-1',
     instanceName='myitblog'
     )