【问题标题】:Unable to create an ec2 instance using boto3无法使用 boto3 创建 ec2 实例
【发布时间】:2019-11-21 20:52:08
【问题描述】:

我无法使用 boto3 创建 EC2 实例。

我正在尝试使用 boto3 创建一个实例。

ec2 = boto3.resource('ec2')
ec2.create_instances(ImageId='ami-0d8f6eb4f641ef691', MinCount=1, MaxCount=1, InstanceType='t2.micro')

我所在的地区是美国东部(俄亥俄州)

我不确定如何找到特定区域的 AMI。我刚刚选择了可用的。

错误信息是

botocore.exceptions.ClientError: An error occurred (InvalidAMIID.NotFound) when calling the RunInstances operation: The image id '[ami-0d8f6eb4f641ef691]' does not exist

我从以下位置复制了 AMI ID:

【问题讨论】:

    标签: python-3.x amazon-web-services amazon-ec2 boto3


    【解决方案1】:

    我认为您缺少 region_name 参数。

    您可以将 region_name 设置为您的代码:

    ec2 = boto3.resource('ec2', region_name='us-east-2')
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-28
      • 1970-01-01
      • 2020-07-20
      • 1970-01-01
      • 2021-11-17
      • 1970-01-01
      • 2021-04-23
      • 2016-06-13
      相关资源
      最近更新 更多