Queries instance Resource Access Management (RAM) roles that are attached to one or more instances.

Description

When you call an API operation by using Alibaba Cloud CLI, you must specify request parameter values of different data types in required formats. For more information, see Parameter format overview.

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

ParameterTypeRequiredExampleDescription
ActionStringYesDescribeInstanceRamRole

The operation that you want to perform. Set the value to DescribeInstanceRamRole.

PageNumberIntegerNo1

The number of the page to return.

Pages start from page 1.

Default value: 1.

PageSizeIntegerNo10

The number of entries to return on each page.

Maximum value: 50.

Default value: 10.

RegionIdStringYescn-hangzhou

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

InstanceIdsStringNo["i-bp67acfmxazb1p****", "i-bp67acfmxazb2p****", "bp67acfmxazb3p****"…]

The IDs of instances. You can specify up to 100 instance IDs in a single request. You must specify at least one of the InstanceIds and RamRoleName parameters.

RamRoleNameStringNoEcsServiceRole-EcsDocGuideTest

The name of the instance RAM role. You can call the ListRoles operation provided by RAM to query the instance RAM roles that you created. You must specify at least one of the InstanceIds and RamRoleName parameters.

Response parameters

ParameterTypeExampleDescription
RequestIdString473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

TotalCountInteger1

The total number of instance RAM roles returned.

RegionIdStringcn-hangzhou

The region ID of the instance RAM role.

InstanceRamRoleSetsArray of InstanceRamRoleSet

Details about the instance RAM roles.

InstanceRamRoleSet
RamRoleNameStringEcsServiceRole-EcsDocGuideTest

The name of the instance RAM role.

InstanceIdStringi-bp67acfmxazb4p****

The ID of the instance

Examples

Sample requests

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

Sample success response

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

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

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

HTTP status codeError codeError messageDescription
400InvalidInstanceIds.MalformedThe specified instanceIds are not valid.The error message returned because the specified InstanceIds parameter is invalid.
500InternalErrorThe request processing has failed due to some unknown error.The error message returned because an internal error has occurred. Try again later.
403InvalidNetworkType.MismatchRamRoleRam role cannot be applied to instances of Classic network type.The error message returned because instance RAM roles can be used only for instances in virtual private clouds (VPCs), not for instances in the classic network.
403InvalidParameter.AllEmpty%sThe error message returned because the required parameters are not specified.
404InvalidInstanceId.NotFoundThe specified instanceId does not existThe error message returned because the specified instance does not exist. Check whether the instance ID is correct.

For a list of error codes, see Service error codes.