简体   繁体   English

无法使用Boto3创建EC2实例

[英]Unable to create an ec2 instance using boto3

I am not able to create an EC2 instance using boto3. 我无法使用boto3创建EC2实例。

I am trying to create an instance using boto3. 我正在尝试使用boto3创建实例。

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

My region is US East(Ohio) 我的地区是美国东部(俄亥俄州)

I am not sure how to find the AMI to a specific region. 我不确定如何找到特定区域的AMI。 I just selected what was available. 我只是选择了可用的。

The error message is 错误消息是

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

and I copied the AMI ID from the: 我从以下位置复制了AMI ID:

在此处输入图片说明

I think you are missing the region_name parameter. 我认为您缺少region_name参数。

You can set the region_name is your code as: 您可以将region_name设置为以下代码:

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

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM