You can call this operation to detach an instance RAM role from one or more ECS instances.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | DetachInstanceRamRole |
The operation that you want to perform. Set the value to DetachInstanceRamRole. |
InstanceIds | String | Yes | ["i-bp67acfmxazb4p****", "i-bp67acfmxazb5p****", "i-bp67acfmxazb6p****"…] |
The IDs of instances from which you want to detach an instance RAM role. It can be a JSON array that consists of up to 100 instance IDs. Separate multiple instance IDs with commas (,). |
RegionId | String | Yes | cn-hangzhou |
The region ID of the instances. You can call the DescribeRegions operation to query the most recent region list. |
RamRoleName | String | No | RamRoleTest |
The name of the instance RAM role to be detached. You can call the ListRoles operation provided by RAM to query the instance RAM roles that you have created. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
DetachInstanceRamRoleResults | Array of DetachInstanceRamRoleResult |
Details about the results of detaching the instance RAM role from the instances. |
|
DetachInstanceRamRoleResult | |||
Code | String | 200 |
The code that indicates whether the instance RAM role was detached. If 200 is returned, the instance RAM role was detached. If any other value is returned, the instance RAM role failed to be detached. For more information, see the "Error codes" section. |
InstanceId | String | i-bp67acfmxazb4p**** |
The ID of the instance from which you attempted to detach the instance RAM role. |
InstanceRamRoleSets | Array of InstanceRamRoleSet |
The details about the instance RAM roles of the instances. |
|
InstanceRamRoleSet | |||
InstanceId | String | i-bp67acfmxazb4p**** |
The ID of the instance from which the RAM role was detached. |
RamRoleName | String | RamRoleTest |
The name of the instance RAM role. |
Message | String | success |
The message that indicates whether the instance RAM role was detached. If success is returned, the instance RAM role was detached. If any other value is returned, the instance RAM role failed to be detached. For more information, see the "Error codes" section. |
Success | Boolean | true |
Indicates whether the RAM role was detached. |
FailCount | Integer | 0 |
The number of the instances from which the RAM role failed to be detached. |
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 the instances from which you detached the RAM role. |
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
<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></RamRoleName>
<FailCount>0</FailCount>
</DetachInstanceRamRoleResponse>
JSON
format
{
"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 error message returned because the specified InstanceIds parameter is invalid. |
403 | InvalidNetworkType.MismatchRamRole | Ram role cannot be applied to instances of Classic network type. | The error message returned because an instance RAM role can be used only for instances in 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 error message returned because the RAM user is not authorized to pass a RAM role. |
For a list of error codes, visit the API Error Center.