![](/img/trans.png)
[英]AWS ElasticBeanstalk boto3 - how to select capacity when creating environment?
[英]Boto3/AWS: “ImageId doesn't exist” when creating Instance
我已經制作了一個AMI的副本,並嘗試使用以下代碼運行它:
import boto3
instance_id=("i-0e2bbdf4fc43bf6db")
client = boto3.client("ec2",region_name="us-west-2")
ec2 = boto3.resource("ec2")
ec2.create_instances(ImageId="ami-9d623ee5",MinCount=1,MaxCount=1)
返回一個ClientError:
ClientError: An error occurred (InvalidAMIID.NotFound) when calling the RunInstances operation: The image id '[ami-9d623ee5]' does not exist
可能是什么問題? 謝謝!
假設AMI位於同一區域...
您的代碼是錯誤的:更改為類似於以下內容:
import boto3
instance_id=("i-0e2bbdf4fc43bf6db")
session = boto3.Session("ec2",region_name="us-west-2")
ec2 = session.resource("ec2")
OR
ec2 = boto3.resource('ec2', region_name='us-west-2')
ec2.create_instances(ImageId="ami-9d623ee5",MinCount=1,MaxCount=1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.