jat*_*tha 17 python amazon-ec2 boto amazon-web-services boto3
我正在尝试使用boto3创建一个现场实例.虽然我遵循API文档,但我收到了一个我无法弄清楚的例外.我正在使用的代码是:
import boto3
import datetime
client = boto3.client('ec2')
response = client.request_spot_instances(
DryRun=False,
SpotPrice='0.10',
ClientToken='string',
InstanceCount=1,
Type='one-time',
LaunchSpecification={
'ImageId': 'ami-fce3c696',
'KeyName': 'awskey.pem',
'SecurityGroups': ['sg-709f8709'],
'InstanceType': 'm4.large',
'Placement': {
'AvailabilityZone': 'us-east-1a',
},
'BlockDeviceMappings': [
{
'Ebs': {
'SnapshotId': 'snap-f70deff0',
'VolumeSize': 100,
'DeleteOnTermination': True,
'VolumeType': 'gp2',
'Iops': 300,
'Encrypted': False
},
},
],
'EbsOptimized': True,
'Monitoring': {
'Enabled': True
},
'SecurityGroupIds': [
'sg-709f8709',
]
}
)
Run Code Online (Sandbox Code Playgroud)
我收到以下例外:
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the RequestSpotInstances operation: Value () for parameter groupId is invalid. The value cannot be empty
Run Code Online (Sandbox Code Playgroud)
问题是API文档中的请求中没有groupId参数.
我错过了什么吗?
jat*_*tha 26
虽然未在API文档中指定,但显然"SecurityGroups"参数需要安全组的名称,而不是ID.
更改为组名解决了该问题.
感谢任何有兴趣首先阅读问题的人.
归档时间: |
|
查看次数: |
5513 次 |
最近记录: |