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
我已将范围考虑为AvailabilityZone
和Availability Zone
。
更新了botocore:sudo pip install botocore --upgrade
从github安装boto3 / botocore:https://github.com/boto/boto3
是否还有其他人使用boto3.resource('ec2')
对象中的方法?
答案 0 :(得分:0)
boto3 documentation for modify_reserved_instance()
将参数显示为:
us-west-2c
standard
或convertible
您的错误消息显示 boto3无法识别Scope
参数。
不表示Scope参数应设置为" AvailabilityZone,Platform,InstanceCount,InstanceType" - 它们只是一个期待的参数列表(而Scope并不是其中之一)。
可转换预留实例became available in September 2016。您的本地boto3
副本似乎已过时。
我建议您将boto3
的版本更新为知道Scope参数的版本:
sudo pip install boto3 --upgrade