All Products
Search
Document Center

Elastic Compute Service:DescribeReservedInstances

Last Updated:Dec 18, 2024

Queries the details of reserved instances that you have purchased. You can query the details of reserved instances based on parameters, such as tags and reserved instance attributes.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:DescribeReservedInstancesget
*ReservedInstance
acs:ecs:{#regionId}:{#accountId}:reservedinstance/*
*ReservedInstance
acs:ecs:{#regionId}:{#accountId}:reservedinstance/{#reservedinstanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the instances. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
PageNumberintegerNo

The page number. Pages start from page 1.

Default value: 1.

1
PageSizeintegerNo

The number of entries per page. Valid values: 1 to 100.

Default value: 10.

50
Tagarray<object>No

The tags of the reserved instance. You can specify up to 20 tags.

objectNo

Tag N of the reserved instance.

KeystringNo

The key of tag N of the reserved instance. The tag key cannot be empty and can be up to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://.

Note If you specify a single tag to query resources, up to 1,000 resources to which the tag is added are returned. If you specify multiple tags to query resources, up to 1,000 resources to which all specified tags are added are returned. To query more than 1,000 resources that have specified tags added, call the ListTagResources operation.
TestKey
ValuestringNo

The value of tag N of the reserved instance. The tag value cannot be empty and can be up to 128 characters in length. It cannot start with acs: and cannot contain http:// or https://.

TestValue
ZoneIdstringNo

The zone ID of the reserved instances. This parameter is required when Scope is set to Zone. You can call the DescribeZones operation to query the most recent zone list.

cn-hangzhou-z
ReservedInstanceNamestringNo

The name of the reserved instance.

testReservedInstanceName
LockReasonstringNo

The reason why the reserved instance is locked. Valid values:

  • financial: The reserved instance is locked because the account has overdue payments or the service expires.
  • security: The reserved instance is locked due to security reasons.
security
InstanceTypestringNo

The instance type. For more information, see Instance families.

ecs.g5.large
InstanceTypeFamilystringNo

The instance family. For more information, see Instance families.

ecs.g5
ScopestringNo

The scope of the reserved instance. Valid values:

  • Region: regional
  • Zone: zonal

Default value: Region.

Region
OfferingTypestringNo

The payment option of the reserved instance. Valid values:

  • No Upfront
  • Partial Upfront
  • All Upfront
All Upfront
AllocationTypestringNo

The allocation type of the reserved instances. Valid values:

  • Normal: queries all reserved instances that belong to the current account.
  • Shared: queries the reserved instances that are shared between the current main account and linked accounts.

Default value: Normal.

Normal
ReservedInstanceIdarrayNo

The IDs of reserved instances. You can specify up to 100 IDs of reserved instances.

stringNo

The ID of reserved instance N.

ri-bpzhex2ulpzf53****
StatusarrayNo

The statuses of the reserved instances.

stringNo

The status of reserved instance N. Valid values:

  • Creating: The reserved instance is being created.
  • Active: The reserved instance is active.
  • Expired: The reserved instance has expired.
  • Updating: The attributes of the reserved instance are being modified.
Active

Response parameters

ParameterTypeDescriptionExample
object
PageSizeinteger

The number of entries per page.

1
RequestIdstring

The request ID.

E572643C-6A29-49D6-9D4E-6CFA4E063A3E
PageNumberinteger

The page number.

1
TotalCountinteger

The total number of reserved instances.

1
ReservedInstancesarray<object>

Details about the reserved instances.

ReservedInstanceobject

Details about the reserved instance.

Statusstring

The status.

Active
CreationTimestring

The creation time.

2018-12-10T12:07Z
ReservedInstanceNamestring

The name.

riZbpzhex2ulpzf53****
ReservedInstanceIdstring

The reserved instance ID.

ri-bpzhex2ulpzf53****
InstanceTypestring

The instance type of the pay-as-you-go instances that can be matched to the reserved instance.

ecs.g5.large
InstanceAmountinteger

The number of pay-as-you-go instances that are of the same instance type as the reserved instance and can be matched to the reserved instance.

10
RegionIdstring

The region ID.

cn-hangzhou
OfferingTypestring

The payment option.

All Upfront
StartTimestring

The effective time.

2018-12-10T12:00Z
Descriptionstring

The description.

testDescription
AllocationStatusstring

Indicates the sharing status of the reserved instance when the AllocationType parameter is set to Shared. Valid values:

  • allocated: The reserved instance is allocated to another account.
  • beAllocated: The reserved instance is allocated by another account.
allocated
ExpiredTimestring

The expiration time.

2019-12-10T12:07Z
ResourceGroupIdstring

The resource group ID.

EcsDocTest
ZoneIdstring

The zone ID.

cn-hangzhou-z
Platformstring

The operating system of the image used by the instance. Valid values:

  • Windows
  • Linux
Linux
Scopestring

The scope.

region
OperationLocksarray<object>

Details about the lock status of the reserved instance.

OperationLockobject

Details about the lock status of the reserved instance.

LockReasonstring

The reason why the instance is locked.

security
Tagsarray<object>

The tags of the reserved instance.

Tagobject

The tag of the reserved instance.

TagValuestring

The tag value.

TestValue
TagKeystring

The tag key.

TestKey

Examples

Sample success responses

JSONformat

{
  "PageSize": 1,
  "RequestId": "E572643C-6A29-49D6-9D4E-6CFA4E063A3E",
  "PageNumber": 1,
  "TotalCount": 1,
  "ReservedInstances": {
    "ReservedInstance": [
      {
        "Status": "Active",
        "CreationTime": "2018-12-10T12:07Z",
        "ReservedInstanceName": "riZbpzhex2ulpzf53****",
        "ReservedInstanceId": "ri-bpzhex2ulpzf53****",
        "InstanceType": "ecs.g5.large",
        "InstanceAmount": 10,
        "RegionId": "cn-hangzhou",
        "OfferingType": "All Upfront",
        "StartTime": "2018-12-10T12:00Z",
        "Description": "testDescription",
        "AllocationStatus": "allocated",
        "ExpiredTime": "2019-12-10T12:07Z",
        "ResourceGroupId": "EcsDocTest",
        "ZoneId": "cn-hangzhou-z",
        "Platform": "Linux",
        "Scope": "region",
        "OperationLocks": {
          "OperationLock": [
            {
              "LockReason": "security"
            }
          ]
        },
        "Tags": {
          "Tag": [
            {
              "TagValue": "TestValue",
              "TagKey": "TestKey"
            }
          ]
        }
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
400MissingParamter.RegionIdThe regionId should not be null.The RegionId parameter is required.
400InvalidRegion.NotFoundThe specified parameter RegionId is not valid.The specified RegionId parameter is invalid.
400InvalidZone.NotFoundThe specified parameter ZoneId is not valid.The specified ZoneId parameter is invalid.
400InvalidReservedInstanceOfferingType.ValueNotSupportedthe OfferingType is not supported-
400InvalidReservedInstanceOfferingClass.ValueNotSupportedthe OfferingClass is not supported-
400OperationDeniedThe specified InstanceType or Zone is not authorized for current user.-
400InvalidEndTime.ValueNotSupportedThe specified endTime is out of the permitted range.The specified end time is invalid.
400InvalidReservedInstanceLockReason.ValueNotSupportedThe specified LockReason is not supported.-
400InvalidReservedInstanceStatus.ValueNotSupportedThe specified Status is not supported.-
400InvalidAllocationType.ValueNotSupportedThe specified AllocationType is not supported.The specified AllocationType parameter is invalid.
404InvalidRegionId.NotFoundThe specified RegionId does not exist in our records.The specified RegionId parameter does not exist. Check whether the service is available in the specified region.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history