Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 无法使用boto3创建ec2实例_Python 3.x_Amazon Web Services_Amazon Ec2_Boto3 - Fatal编程技术网

Python 3.x 无法使用boto3创建ec2实例

Python 3.x 无法使用boto3创建ec2实例,python-3.x,amazon-web-services,amazon-ec2,boto3,Python 3.x,Amazon Web Services,Amazon Ec2,Boto3,我无法使用boto3创建EC2实例 ec2 = boto3.resource('ec2') ec2.create_instances(ImageId='ami-0d8f6eb4f641ef691', MinCount=1, MaxCount=1, InstanceType='t2.micro') 我正在尝试使用boto3创建一个实例 ec2 = boto3.resource('ec2') ec2.create_instances(ImageId='ami-0d8f6eb4f641ef691',

我无法使用boto3创建EC2实例

ec2 = boto3.resource('ec2')
ec2.create_instances(ImageId='ami-0d8f6eb4f641ef691', MinCount=1, MaxCount=1, InstanceType='t2.micro')
我正在尝试使用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:


我认为您缺少region\u name参数

您可以将代码中的区域名称设置为:

ec2 = boto3.resource('ec2', region_name='us-east-2')
希望能有帮助