All Products
Search
Document Center

:DetachInstanceRamRole

更新时间:Dec 13, 2023

Detaches instance Resource Access Management (RAM) roles from ECS instances.

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 DetachInstanceRamRole

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

RegionId String Yes cn-hangzhou

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

RamRoleName String No RamRoleTest

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.

InstanceIds String Yes ["i-bp67acfmxazb4p****", "i-bp67acfmxazb5p****", "i-bp67acfmxazb6p****"…]

The IDs of instances. The value can be a JSON array that consists of up to 100 instance IDs. Separate the instance IDs with commas (,).

Response parameters

Parameter

Type

Example

Description

RamRoleName String RamRoleTest

The name of the instance RAM role.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

TotalCount Integer 1

The total number of instances from which you attempted to detach instance RAM roles.

FailCount Integer 0

The number of instances from which instance RAM roles failed to be detached.

DetachInstanceRamRoleResults Array of DetachInstanceRamRoleResult

The results of detaching the instance RAM role from the instances.

DetachInstanceRamRoleResult
Code String 200

Indicates whether the instance RAM role was detached. The status code 200 indicates that the request was successful. Other status codes indicate that the request failed.

Message String Success

Indicates whether the instance RAM role was detached. The status code Success indicates that the request was successful. Other status codes indicate that the request failed. For more information, see the "Error codes" section in this topic.

InstanceId String i-bp67acfmxazb4p****

The ID of the instance from which you attempted to detach the instance RAM role.

Success Boolean true

Indicates whether the instance RAM role was detached.

InstanceRamRoleSets Array of InstanceRamRoleSet

The instance RAM roles of the instances.

InstanceRamRoleSet
RamRoleName String RamRoleTest

The name of the instance RAM role.

InstanceId String i-bp67acfmxazb4p****

The ID of the instance.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=DetachInstanceRamRole
&InstanceIds=["i-bp67acfmxazb4p****", "i-bp67acfmxazb5p****", "i-bp67acfmxazb6p****"…]
&RegionId=cn-hangzhou
&RamRoleName=RamRoleTest
&<Common request parameters>

Sample success responses

XML format

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

<DetachInstanceRamRoleResponse>
    <TotalCount>1</TotalCount>
    <DetachInstanceRamRoleResults>
        <DetachInstanceRamRoleResult>
            <Message>success</Message>
            <InstanceId>i-bp16qng6jnvt6g7t****</InstanceId>
            <Code>200</Code>
            <InstanceRamRoleSets>
                <InstanceId>i-bp16qng6jnvt6g7t****</InstanceId>
                <RamRoleName>RamRoleTest</RamRoleName>
            </InstanceRamRoleSets>
        </DetachInstanceRamRoleResult>
    </DetachInstanceRamRoleResults>
    <RequestId>14D5B163-CE6C-4489-B979-DBE5D0495A63</RequestId>
    <RamRoleName/>
    <FailCount>0</FailCount>
</DetachInstanceRamRoleResponse>

JSON format

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

{
  "TotalCount" : 1,
  "DetachInstanceRamRoleResults" : {
    "DetachInstanceRamRoleResult" : [ {
      "Message" : "success",
      "InstanceId" : "i-bp16qng6jnvt6g7t****",
      "Code" : "200",
      "InstanceRamRoleSets" : {
        "InstanceId" : "i-bp16qng6jnvt6g7t****",
        "RamRoleName" : "RamRoleTest"
      }
    } ]
  },
  "RequestId" : "14D5B163-CE6C-4489-B979-DBE5D0495A63",
  "RamRoleName" : "",
  "FailCount" : 0
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidInstanceIds.Malformed The specified instanceIds are not valid. The specified Instance IDs are invalid.
403 InvalidNetworkType.MismatchRamRole Ram role cannot be applied to instances of Classic network type. Instance RAM roles can be used only for instances in virtual private clouds (VPCs), not for instances in the classic network.
403 InvalidUser.PassRoleForbidden The RAM user does not have the privilege to pass a RAM role. The RAM user does not have the permissions to pass a RAM role.
404 InvalidInstanceId.NotFound The specified instanceId does not exist. The specified instance ID is not found.

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