简体   繁体   English

AWS修改保留实例

[英]aws modify reserved instances

Have an issue with AWS python boto3 call ec2.meta.client.modify_reserved_instances() . AWS python boto3遇到问题,请致电ec2.meta.client.modify_reserved_instances()

I am getting the error below: 我收到以下错误:

botocore.exceptions.ParamValidationError: Parameter validation failed: Unknown parameter in TargetConfigurations[0]: "Scope", must be one of: AvailabilityZone, Platform, InstanceCount, InstanceType botocore.exceptions.ParamValidationError:参数验证失败:TargetConfigurations [0]中的未知参数:“ Scope”,必须为以下之一:AvailabilityZone,Platform,InstanceCount,InstanceType

This is my function: 这是我的功能:

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

I have tried the Scope as AvailabilityZone and Availability Zone . 我已经尝试将Scope用作AvailabilityZoneAvailability Zone

  • Updated botocore: sudo pip install botocore --upgrade 更新的botocore: sudo pip install botocore --upgrade

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

Has anyone else used the method from boto3.resource('ec2') object? 有没有其他人使用过boto3.resource('ec2')对象中的方法?

The boto3 documentation for modify_reserved_instance() shows parameters as: bot3文档modify_reserved_instance()参数如下:

  • AvailabilityZone: eg us-west-2c AvailabilityZone:例如us-west-2c
  • Platform: Either EC2-Classic or EC2-VPC 平台: EC2-Classic或EC2-VPC
  • InstanceCount 实例数
  • InstanceType 实例类型
  • Scope: standard or convertible 范围: standardconvertible

Your error message says that boto3 does not recognise the Scope parameter . 您的错误消息说boto3无法识别Scope参数

It is not saying that the Scope parameter should be set to "AvailabilityZone, Platform, InstanceCount, InstanceType" -- they are simply a list of parameters that it is expecting (and Scope isn't one of them). 并不是说Scope参数应该设置为“ AvailabilityZone,Platform,InstanceCount,InstanceType”,它们只是期望的参数列表(而Scope不是其中之一)。

Convertible Reserved Instances became available in September 2016 . 可转换的预留实例于2016年9月可用 It would appear that your local copy of boto3 is out-of-date. 您的boto3本地副本boto3已过期。

I suggest you update your version of boto3 to a version that knows the Scope parameter: 我建议您将boto3的版本更新为知道Scope参数的版本:

sudo pip install boto3 --upgrade

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM