【发布时间】:2016-03-28 10:55:58
【问题描述】:
client = boto3.client('ec2',
aws_access_key_id=key,
aws_secret_access_key=secret,
region_name='ap-southeast-1')
response = client.create_instances(
DryRun=True,
ImageId=ami1,
MinCount=1,
MaxCount=1,
KeyName='my-key',
SecurityGroupIds=[sg1, sg2],
InstanceType='m3.medium',
Placement={
'AvailabilityZone': 'ap-southeast-1a'
},
SubnetId=sb1,
NetworkInterfaces=[
{
'NetworkInterfaceId': vpc1,
'SubnetId': sb1,
'Description': 'Description'
}
]
)
print response
调用 api 来创建实例时出错,我已经验证过诸如 describe_images 之类的其他操作工作正常,所以键是正确的。
我错过了什么吗?
【问题讨论】:
-
第 1 行不应该是
boto3.resource('ec2'...而不是boto3.client('ec2'...?
标签: python amazon-web-services amazon-ec2 boto3