You can call this operation to query the instance RAM roles that have been assigned to one or more ECS instances.

Description

When you call an API operation through Alibaba Cloud Command Line Interface (CLI), specify request parameter values of different data types in required formats. For more information, see CLI parameter format.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeInstanceRamRole

The operation that you want to perform. For API requests using the HTTP and HTTPS methods, the Action parameter is required. Set the value to DescribeInstanceRamRole.

RegionId String Yes cn-hangzhou

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

PageNumber Integer No 1

The number of the page to return.

Pages start from page 1.

Default value: 1.

PageSize Integer No 10

The number of entries to return on each page.

Valid values: 1 to 50.

Default value: 10.

InstanceIds String No ["i-bp67acfmxazb4ph***", "i-bp67acfmxazb4pi***", "bp67acfmxazb4pj***"…]

The ID collection of instances that you want to query. A maximum of 100 instances can be entered at a time. You must specify at least one of the InstanceIds and RamRoleName parameters.

RamRoleName String No EcsServiceRole-EcsDocGuideTest

The name of the instance RAM role. This parameter can be used to query all the ECS instances to which the instance RAM role is assigned. You can call the ListRoles operation to query the RAM roles that you have created. You must specify at least one of the InstanceIds and RamRoleName parameters.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

RegionId String cn-hangzhou

The region ID of the instance RAM role.

TotalCount Integer 1

The total number of returned RAM roles.

InstanceRamRoleSets Array

The returned RAM role information. It is an array that consists of InstanceRamRoleSet data.

InstanceId String i-bp67acfmxazb4ph***

The ID of the instance.

RamRoleName String EcsServiceRole-EcsDocGuideTest

The name of the instance RAM role.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=DescribeInstanceRamRole
&RegionId=cn-hangzhou
&InstanceIds=["i-bp67acfmxazb4ph***"]
&PageNumber=1
&PageSize=1
&<Common request parameters>

Sample success response

XML format

<DescribeInstanceRamRoleResponse>
      <RequestId>8F4CAE3F-7892-4662-83A5-2C2FFD639553</RequestId>
      <InstanceRamRoleSets>
            <InstanceRamRoleSet>
                  <InstanceId>i-bp67acfmxazb4ph***</InstanceId>
                  <RamRoleName>EcsServiceRole-EcsDocGuideTest</RamRoleName>
            </InstanceRamRoleSet>
      </InstanceRamRoleSets>
      <TotalCount>1</TotalCount>
      <PageNumber>1</PageNumber>
      <PageSize>1</PageSize>
</DescribeInstanceRamRoleResponse>

JSON format

{
    "RequestId": "8F4CAE3F-7892-4662-83A5-2C2FFD639553",
    "InstanceRamRoleSets": {
        "InstanceRamRoleSet": [
            {
                "InstanceId": "i-bp67acfmxazb4ph***",
                "RamRoleName": "EcsServiceRole-EcsDocGuideTest"
            }
        ]
    },
    "TotalCount": 1,
    "PageNumber": 1,
    "PageSize": 1
}

Error codes

HTTP status code Error code Error message Description
400 InvalidInstanceIds.Malformed The specified instanceIds are not valid. The error message returned because multiple specified values of the InstanceId parameter are invalid.
404 InvalidInstanceId.NotFound The specified instanceId does not exist The error message returned because the specified instance ID does not exist.
403 InvalidNetworkType.MismatchRamRole Ram role cannot be applied to instances of Classic network type. The error message returned because the specified instance is classic network-type instance. An instance RAM role can only be used for VPC-type instances.
403 InvalidParameter.AllEmpty %s The error message returned because you did not specify the required parameter.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred. Try again later. If the problem persists, submit a ticket.

For a list of error codes, visit the API Error Center.