2016-03-01 15 views
10

私はboto3を使用してスポットインスタンスを作成しようとしています。私はAPI documentationに従っていますが、私は把握できない例外があります。boto3:スポットインスタンスの作成

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', 
     ] 
    } 
) 

そして、私は次の例外を受け取ります:私が使用しているコードがある

botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the RequestSpotInstances operation: Value() for parameter groupId is invalid. The value cannot be empty 

API documentationにおける要求にはgroupIdをパラメータが存在しないです。

何か不足していますか?

答えて

16

APIドキュメントでは指定されていませんが、明らかに 'SecurityGroups'パラメータにはIDではなくセキュリティグループの名前が必要です。

グループ名を変更すると問題が解決しました。

最初の質問を読んでくれてありがとうございました。

+5

これで時間が節約されました。 – Brett

関連する問題