【问题标题】:aws modify reserved instancesaws 修改保留实例
【发布时间】:2016-10-30 16:07:06
【问题描述】:

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')对象的方法?

【问题讨论】:

  • 虽然与错误消息没有明显关系(这表明字符串中的空格肯定需要删除),但这似乎是错误的:{ 'AvailabilityZone': region, ... } A region is not the same thing as a availability zone .例如,us-west-2 是区域,us-west-2c 是区域内的可用区。

标签: python amazon-web-services boto3


【解决方案1】:

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

【讨论】:

  • 这是我的问题 api_version='2016-04-01'
猜你喜欢
  • 2021-11-11
  • 1970-01-01
  • 2021-12-26
  • 2015-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-24
相关资源
最近更新 更多