DescribeReservedInstances

更新时间:
复制 MD 格式

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

Operation description

Scenarios

  • Query all reserved instances in a specific region.

  • Query the details of a reserved instance based on the ID or name.

  • Query your purchased reserved instances based on the instance type or instance family.

  • Query your purchased reserved instances based on the scope or status of reserved instances.

Sample requests

Example: Query all purchased reserved instances in the China (Hangzhou) region

"RegionId":"cn-hangzhou", //The ID of the region.

Example: Query the details of the reserved instance whose ID is ecsri-bp129enntoynwwj5**** in the China (Hangzhou) region

"RegionId":"cn-hangzhou", //The ID of the region."ReservedInstanceId":"ecsri-bp129enntoynwwj5****" //The ID of the reserved instance.

Example: Query the reserved instances that can be used to offset the bills of ecs.c5.2xlarge instances in the China (Hangzhou) region

"RegionId":"cn-hangzhou", //The ID of the region."InstanceType":"ecs.c5.2xlarge", //The instance type.

Example: Query the regional reserved instances that are within the validity period in the China (Hangzhou) region

"RegionId":"cn-hangzhou", //The ID of the region."Scope":"Region", //Set the scope of the reserved instance to regional."Status":["Active"] //Set the status to Active, which indicates that the reserved instance is within the validity period.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:DescribeReservedInstances

get

ReservedInstance

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

ReservedInstance

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

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

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

cn-hangzhou

PageNumber

integer

No

The page number. Pages start from page 1.

Default value: 1.

1

PageSize

integer

No

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

Default value: 10.

50

Tag

array<object>

No

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

object

No

Tag N of the reserved instance.

Key

string

No

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

Value

string

No

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

RegionId

string

Yes

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

cn-hangzhou

ZoneId

string

No

The zone ID of the reserved instance. This parameter is valid and required if you set Scope to Zone. You can call the DescribeZones operation to query the most recent zone list.

cn-hangzhou-z

ReservedInstanceName

string

No

The name of the reserved instance.

Note

Only exact search is supported.

testReservedInstanceName

LockReason

string

No

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

InstanceType

string

No

The instance type of the reserved instance. For information about the valid values, see Overview of instance families.

Note

Specify the instance type that you selected when you purchased the reserved instance. If the reserved instance is a regional reserved instance, it can be used to offset the bills of instance types that belong to the same instance family as the specified instance type, regardless of instance specifications.

ecs.g5.large

InstanceTypeFamily

string

No

The instance family of the reserved instance. For information about the valid values, see Overview of instance families.

ecs.g5

Scope

string

No

The scope level of the reserved instance. Valid values:

  • Region: regional

  • Zone: zonal

Region

OfferingType

string

No

The payment option of the reserved instance. Valid values:

  • No Upfront

  • Partial Upfront

  • All Upfront

All Upfront

AllocationType

string

No

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

ReservedInstanceId

array

No

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

ri-bpzhex2ulpzf53****

string

No

The ID of reserved instance N.

ri-bpzhex2ulpzf53****

Status

array

No

The status of the reserved instances.

Active

string

No

The status of reserved instance N. Valid values:

  • Creating: The reserved instance is being created.

  • Active: The reserved instance is active.

  • Retired: The reserved instance expired.

  • Updating: The attributes of the reserved instance are being modified.

  • Expired: The reserved instance has expired. The reserved instance becomes invalid immediately after it expires. This value is currently obsolete and will be removed in the future.

Active

Response elements

Element

Type

Description

Example

object

PageSize

integer

The number of entries per page.

1

RequestId

string

The request ID.

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

PageNumber

integer

The page number.

1

TotalCount

integer

The total number of reserved instances.

1

ReservedInstances

object

ReservedInstance

array<object>

Details about the reserved instances.

array<object>

Details about the reserved instance.

Status

string

The status.

Active

CreationTime

string

The creation time.

2018-12-10T12:07Z

ReservedInstanceName

string

The name.

riZbpzhex2ulpzf53****

ReservedInstanceId

string

The reserved instance ID.

ri-bpzhex2ulpzf53****

InstanceType

string

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

ecs.g5.large

InstanceAmount

integer

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

RegionId

string

The region ID.

cn-hangzhou

OfferingType

string

The payment option.

All Upfront

StartTime

string

The effective time.

2018-12-10T12:00Z

Description

string

The description.

testDescription

AllocationStatus

string

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

ExpiredTime

string

The expiration time.

2019-12-10T12:07Z

ResourceGroupId

string

The resource group ID.

EcsDocTest

ZoneId

string

The zone ID.

cn-hangzhou-z

Platform

string

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

  • Windows

  • Linux

Linux

Scope

string

The scope.

region

OperationLocks

object

OperationLock

array<object>

Details about the lock status of the reserved instance.

object

Details about the lock status of the reserved instance.

LockReason

string

The reason why the instance is locked.

security

Tags

object

Tag

array<object>

The tags of the reserved instance.

object

The tag of the reserved instance.

TagValue

string

The tag value.

TestValue

TagKey

string

The tag key.

TestKey

Examples

Success response

JSON format

{
  "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 response

JSON format

{
    "code":"200",
    "data":{
        "data":[
            {
                "CreationTime":"2018-12-10T12:07Z",
                "ExpiredTime":"2019-12-10T16:00Z",
                "InstanceAmount":1,
                "ReservedInstanceId":"ri-0xzhex2ulpzf53rxme2j",
                "InstanceType":"ecs.g5.large",
                "OfferingType":"All Upfront",
                "RegionId":"cn-hangzhou-test-307",
                "ReservedInstanceName":"riZ0xzhex2ulpzf53rxme2jZ",
                "Scope":"region",
                "StartTime":"2018-12-10T12:00Z",
                "Status":"active"
            }
        ],
        "PageNumber":1,
        "PageSize":50,
        "Total":1
    },
    "httpStatusCode":200,
    "message":"successful",
    "requestId":"E572643C-6A29-49D6-9D4E-6CFA4E063A3E",
    "success":true
}

Error codes

HTTP status code

Error code

Error message

Description

400 MissingParamter.RegionId The regionId should not be null. The RegionId parameter is required.
400 InvalidRegion.NotFound The specified parameter RegionId is not valid. The specified RegionId parameter is invalid.
400 InvalidZone.NotFound The specified parameter ZoneId is not valid. The specified ZoneId parameter is invalid.
400 InvalidReservedInstanceOfferingType.ValueNotSupported the OfferingType is not supported
400 InvalidReservedInstanceOfferingClass.ValueNotSupported the OfferingClass is not supported
400 OperationDenied The specified InstanceType or Zone is not authorized for current user.
400 InvalidEndTime.ValueNotSupported The specified endTime is out of the permitted range. The specified end time is invalid.
400 InvalidReservedInstanceLockReason.ValueNotSupported The specified LockReason is not supported.
400 InvalidReservedInstanceStatus.ValueNotSupported The specified Status is not supported.
400 InvalidAllocationType.ValueNotSupported The specified AllocationType is not supported. The specified AllocationType parameter is invalid.
403 RAM.ApiNotSupported This call is not supported from ram accessing. RAM users are not authorized to perform this operation.
404 InvalidRegionId.NotFound The 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.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.