简体   繁体   中英

aws modify reserved instances

Have an issue with AWS python boto3 call 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

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 .

  • Updated botocore: sudo pip install botocore --upgrade

  • Installed boto3/botocore from github: https://github.com/boto/boto3

Has anyone else used the method from boto3.resource('ec2') object?

The boto3 documentation for modify_reserved_instance() shows parameters as:

  • AvailabilityZone: eg us-west-2c
  • Platform: Either EC2-Classic or EC2-VPC
  • InstanceCount
  • InstanceType
  • Scope: standard or convertible

Your error message says that boto3 does not recognise the Scope parameter .

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).

Convertible Reserved Instances became available in September 2016 . It would appear that your local copy of boto3 is out-of-date.

I suggest you update your version of boto3 to a version that knows the Scope parameter:

sudo pip install boto3 --upgrade

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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