回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在尝试使用boto3创建一个spot实例。尽管我遵循<a href="http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.Client.request_spot_instances" rel="noreferrer">API documentation</a>,但我收到了一个无法解决的异常。我使用的代码是:</p>
<pre><code>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',
]
}
)
</code></pre>
<p>我收到以下异常:</p>
<pre><code>botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the RequestSpotInstances operation: Value () for parameter groupId is invalid. The value cannot be empty
</code></pre>
<p>问题是<a href="http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.Client.request_spot_instances" rel="noreferrer">API documentation</a>中的请求中没有groupId参数。</p>
<p>我遗漏了什么吗?</p>