簡體   English   中英

AWS修改保留實例

[英]aws modify reserved instances

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

我已經嘗試將Scope用作AvailabilityZoneAvailability Zone

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

  • 從github安裝了boto3 / botocore: https://github.com/boto/boto3 : https://github.com/boto/boto3

有沒有其他人使用過boto3.resource('ec2')對象中的方法?

bot3文檔modify_reserved_instance()參數如下:

  • AvailabilityZone:例如us-west-2c
  • 平台: EC2-Classic或EC2-VPC
  • 實例數
  • 實例類型
  • 范圍: standardconvertible

您的錯誤消息說boto3無法識別Scope參數

並不是說Scope參數應該設置為“ AvailabilityZone,Platform,InstanceCount,InstanceType”,它們只是期望的參數列表(而Scope不是其中之一)。

可轉換的預留實例於2016年9月可用 您的boto3本地副本boto3已過期。

我建議您將boto3的版本更新為知道Scope參數的版本:

sudo pip install boto3 --upgrade

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM