全部產品
Search
文件中心

Elastic Compute Service:ModifyReservedInstances - 修改預留執行個體券配置

更新時間:Apr 04, 2026

本介面的主要功能是通過修改執行個體規格、數量、可用性區域等預留執行個體券的配置來對預留執行個體券進行拆分、合并或範圍變更操作。

介面說明

本介面為非同步介面,介面調用成功後會返回新產生的預留執行個體券 ID,原來的預留執行個體券會進入更新中狀態,最終變為失效狀態,與此同時,會有一張建立中狀態的預留執行個體券產生,最終變為已生效狀態,您可以通過 DescribeReservedInstances 進行查詢。

  • 預留執行個體券只有在已生效狀態下才可以修改配置。

  • 請確保修改配置前後預留執行個體券的計算力不會改變,否則修改請求會失敗。

  • 預留執行個體券的拆分、合并、範圍變更不能同時進行。

更多資訊,請參見拆分、合并或修改預留執行個體券

請求樣本

  • 拆分:將一張杭州地區、執行個體規格為 ecs.g5.xlarge、匹配數量為 2 的預留執行個體券拆分為兩張執行個體規格為 ecs.g5.large、匹配數量為 1 的預留執行個體券。

"RegionId":"cn-hangzhou", //設定地區為杭州
"ReservedInstanceId":["ecsri-bp1hd03e9uv19e75****"], //需要拆分的預留執行個體券 ID
"Configuration":[
  {
    "ReservedInstanceName":"testReservedInstanceName1", //修改後的預留執行個體券名稱
    "InstanceType":"ecs.g5.large", //設定修改後的執行個體規格
    "Scope":"Region", //預留執行個體券的範圍不可改變
    "InstanceAmount":1 //表示預留執行個體券可以同時匹配同規格隨用隨付執行個體的數量為 1 台
  },
  {
    "ReservedInstanceName":"testReservedInstanceName2",
    "InstanceType":"ecs.g5.large",
    "Scope":"Region",
    "InstanceAmount":1
  }
]

  • 合并:將兩張杭州地區可用性區域 H 、執行個體規格為 ecs.g5.xlarge、匹配數量為 4 的預留執行個體券合并為一張執行個體規格為 ecs.g5.4xlarge、匹配數量為 2 的預留執行個體券。

"RegionId":"cn-hangzhou", //設定地區為杭州
"ReservedInstanceId":["ecsri-bp1hd03e9uv16b75****",""ecsri-bp1hd03e9uv16b76****""], //需要合并的預留執行個體券 ID
"Configuration":[
  {
    "ReservedInstanceName":"testReservedInstanceName", //修改後的預留執行個體券名稱
    "InstanceType":"ecs.g5.4xlarge", //設定修改後的執行個體規格
    "Scope":"Zone", //預留執行個體券的範圍不可改變
    "ZoneId":"cn-hangzhou-h", //
    "InstanceAmount":2 //表示預留執行個體券可以同時匹配同規格隨用隨付執行個體的數量為 2 台
  }
]
  • 變更範圍:將一張杭州地區可用性區域 H 、執行個體規格為 ecs.g5.xlarge、匹配數量為 6 的預留執行個體券變更為一張杭州地區、執行個體規格為 ecs.g5.2xlarge、匹配數量為 3 的預留執行個體券。

"RegionId":"cn-hangzhou", //設定地區為杭州
"ReservedInstanceId":["ecsri-bp1hd03e9uv16b77****"], //需要變更範圍的預留執行個體券 ID
"Configuration":[
  {
    "ReservedInstanceName":"testReservedInstanceName", //變更範圍後的預留執行個體券名稱
    "InstanceType":"ecs.g5.2xlarge", //設定修改後的執行個體規格
    "Scope":"Region", //變更後預留執行個體券的範圍
    "InstanceAmount":3 //表示預留執行個體券可以同時匹配同規格隨用隨付執行個體的數量為 3 台
  }
]

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

ecs:ModifyReservedInstances

update

*ReservedInstance

acs:ecs:{#regionId}:{#accountId}:reservedinstance/{#reservedinstanceId}

請求參數

名稱

類型

必填

描述

樣本值

RegionId

string

預留執行個體券所屬的地區 ID。

您可以調用 DescribeRegions 擷取最新的阿里雲地區列表。

cn-hangzhou

ReservedInstanceId

array

預留執行個體券 ID 數組。數組長度:1~20。

ReservedInstanceId.1="ecsri-bp1cx3****",ReservedInstanceId.2="ecsri-bp15xx2****"......

string

預留執行個體券 ID。

ecsri-bp15xx2****

Configuration

array<object>

預留執行個體券的配置資訊數組。數組長度:1~100。

object

預留執行個體券的配置資訊。

ReservedInstanceName

string

預留執行個體券的名稱。

長度為 2~128 個英文或中文字元。必須以大小寫字母或中文開頭,不能以 http://和 https://開頭。可以包含數字、半形冒號(:)、底線(_)或者短劃線(-)。

testReservedInstanceName

ZoneId

string

預留執行個體券所屬的可用性區域編號。

Scope參數值為Zone時,該參數為必填參數。

您可以調用 DescribeZones 擷取可用性區域列表。

cn-hangzhou-i

Scope

string

預留執行個體券的範圍。取值範圍:

  • Region:地區層級。

  • Zone:可用性區域層級。

預設值:Region。

Zone

InstanceType

string

預留執行個體券可以匹配的執行個體規格。

說明

適用的執行個體規格持續更新,詳情請參見預留執行個體券概述

ecs.c5.4xlarge

InstanceAmount

integer

預留執行個體券可以同時匹配同規格隨用隨付執行個體的數量。取值範圍:≥1。

1

返回參數

名稱

類型

描述

樣本值

object

RequestId

string

請求 ID。

ED9E4A5F-FF4D-4C96-BE80-6B4227060DD7

ReservedInstanceIdSets

object

ReservedInstanceId

array

預留執行個體券 ID 列表。

string

預留執行個體券 ID。

"ecsri-bp1cx3****"

樣本

正常返回樣本

JSON格式

{
  "RequestId": "ED9E4A5F-FF4D-4C96-BE80-6B4227060DD7",
  "ReservedInstanceIdSets": {
    "ReservedInstanceId": [
      "\"ecsri-bp1cx3****\""
    ]
  }
}

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 InvalidInstanceType.ValueUnauthorized The specified InstanceType is not authorized.
400 InvalidParameter.Conflict The specified region and cluster do not match. 指定的地區與指定的叢集不匹配。
400 InvalidTagKey.Malformed The specified Tag.n.Key is not valid. 指定的標籤鍵參數有誤。
400 InvalidPeriodUnit.ValueNotSupported The specified parameter PeriodUnit is not valid. 參數 PeriodUnit 無效。
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. 指定的標籤值參數有誤。
400 InvalidChargeType.ValueNotSupported ChargeType is not valid.
400 OperationDenied The specified InstanceType or Zone is not authorized for current user.
500 InternalError The request processing has failed due to some unknown error.
403 OperationDenied.NoStock The requested resource is sold out in the specified zone; try other types of resources or other regions and zones. 庫存不足。
403 OperationDenied Sales of this resource are temporarily suspended in the specified region; please try again later. 指定的地區暫時關閉了此資源的售賣,請稍後重試。
403 NodeControllerUnavailable The Node Controller is temporarily unavailable.
403 InvalidParameter.ResourceOwnerAccount ResourceOwnerAccount is Invalid. 指定的 ResourceOwnerAccount 不合法。
403 Zone.NotOpen The specified zone is not granted to you to buy resources yet.
403 Zone.NotOnSale The specified zone is not available for purchase. 指定可用性區域已經售罄,請您更換執行個體規格或者更換地區建立。
403 Account.Arrearage Your account has been in arrears.
403 InvalidReservedInstanceName.Malformed The specified parameter ReservedInstanceName is invalid.
403 InvalidParameter.Scope The specified parameter 'Scope' is invalid.
403 InvalidReservedInstanceStatus.ValueNotSupported ReservedInstance status is not supported.
403 InvalidReservedInstanceOfferingType.ValueNotSupported The OfferingType is not supported.
403 InvalidReservedInstanceOfferingClass.ValueNotSupported The OfferingClass is not supported.
403 MissingParameter.ZoneId The specified zoneId should be not empty.
403 MissingParameter.InstanceType The instanceType should be not empty.
403 MissingParameter.ReservedInstanceId The ids of reservedInstance can not be empty.
403 MissingParameter.ReservedInstanceConfiguration The configurations of reservedInstance can not be empty.
403 InvalidParameter.SplitOrMerge The Many-to-many of modification is not supported.
403 MissingParameter.InstanceTypeAndAmountBothEmpty The instanceType and amount can not be both empty.
403 InvalidReservedInstancePlatform.ValueNotSupported The Platform is not supported.
403 InvalidParameter.ReservedInstanceName The reservedInstanceName is invalid. reservedInstanceName欄位值不合法
403 InvalidReservedInstanceZone.ValueNotSupported The zoneId is not exist.
403 InvalidParameter.ValueNotSupported The instanceTypeFamily of the instance to be changed must be consistent.
403 IncorrectInstanceStatus The status of specified reservedInstance must be active. 預留執行個體券狀態不正確導致續約失敗
403 InvalidPlatform.ValueNotSupported The platform of reservedInstance is invalid.
403 InvalidScope.ValueNotSupported The scope of reservedInstance is invalid. The valid value is Zone or Region.
403 InvalidConfiguration.ValueNotSupported The modification Configuration should not be empty.
403 InvalidZoneId.ValueNotSupported The specified zoneId should be same.
403 InvalidParameter The parameter is invalid.Please check it.
403 InvalidInstanceAmount.ValueNotSupported The instanceAmount is invalid.
403 OperationDenied.OnlyModifyName It is not allowed to modify the ReservedInstanceName only. 不允許只修改預留執行個體券的名稱。
403 InvalidReservedInstanceId.NotFound The specified parameter ReservedInstanceId is invalid.
404 InvalidZoneId.NotFound The ZoneId provided does not exist in our records.

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情