aws修改保留的实例

时间:2016-10-28 11:01:32

标签: python amazon-web-services boto3

AWS python boto3调用ec2.meta.client.modify_reserved_instances()时遇到问题。

我收到以下错误:

  

botocore.exceptions.ParamValidationError:参数验证失败:   TargetConfigurations [0]中的未知参数:" Scope",必须是以下之一:AvailabilityZone,Platform,InstanceCount,InstanceType

这是我的功能:

def modify_reserved_instance(self, region, iid, icount, itype):
    ec2 = boto3.resource(
    'ec2', region_name=region[:-1], api_version='2016-04-01')

    response = ec2.meta.client.modify_reserved_instances(
    ClientToken='string',
    ReservedInstancesIds=[
    iid,
    ],
    TargetConfigurations=[
    {
    'AvailabilityZone': region,
    'Platform': 'Linux/UNIX (Amazon VPC)',
    'InstanceCount': icount,
    'InstanceType': itype,
    'Scope': 'Availability Zone'
    },
    ]
    )
    print (response)
    return response

我已将范围考虑为AvailabilityZoneAvailability Zone

  • 更新了botocore:sudo pip install botocore --upgrade

  • 从github安装boto3 / botocore:https://github.com/boto/boto3

是否还有其他人使用boto3.resource('ec2')对象中的方法?

1 个答案:

答案 0 :(得分:0)

boto3 documentation for modify_reserved_instance()将参数显示为:

  • AvailabilityZone:例如us-west-2c
  • 平台: EC2-Classic或EC2-VPC
  • InstanceCount
  • InstanceType
  • 范围: standardconvertible

您的错误消息显示 boto3无法识别Scope参数

表示Scope参数应设置为" AvailabilityZone,Platform,InstanceCount,InstanceType" - 它们只是一个期待的参数列表(而Scope并不是其中之一)。

可转换预留实例became available in September 2016。您的本地boto3副本似乎已过时。

我建议您将boto3的版本更新为知道Scope参数的版本:

sudo pip install boto3 --upgrade