簡體   English   中英

無法使用Boto3創建EC2實例

[英]Unable to create an ec2 instance using boto3

我無法使用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:

在此處輸入圖片說明

我認為您缺少region_name參數。

您可以將region_name設置為以下代碼:

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

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM