Detaches a key pair from up to 30 instances in a single request. You can specify the key pair by its key pair name or key pair ID.
Operation description
Usage notes
This operation detaches a key pair from multiple instances in a batch. The target instances must be in a stopped state.
You can detach a key pair from a maximum of 30 instances in a single request.
The operation returns an error if you specify the
KeyPairNameparameter and any of the specified instances are not associated with that key pair name.You must specify either the
KeyPairNameorKeyPairIdparameter.We recommend using the
KeyPairIdparameter. TheKeyPairNameparameter will be deprecated in a future release.
Try it now
Test
RAM authorization
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| KeyPairName |
string |
No |
The name of the key pair. |
test-kp |
| KeyPairId |
string |
No |
The ID of the key pair. |
ssh-xxx |
| InstanceIds |
array |
Yes |
An array of instance IDs from which to detach the key pair. |
["i-50f8q9mbfjzlkuk9znjglnne3"] |
|
string |
No |
An instance ID. |
i-xxxu |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response object. |
||
| RequestId |
string |
The request ID. |
xx-xx-xx-xx |
| KeyPairId |
string |
The ID of the key pair. |
ssh-xxx |
| KeyPairName |
string |
The name of the key pair. |
test-kp |
| FailCount |
integer |
The number of instances for which the detach operation failed. |
1 |
| TotalCount |
integer |
The total number of instances specified in the request. |
3 |
| Results |
array<object> |
The results of the operation for each instance. |
|
|
object |
|||
| Code |
integer |
The status code for the operation on a specific instance. A value of |
200 |
| InstanceId |
string |
The instance ID. |
i-xxx |
| Message |
string |
The response message for the operation. If the |
successful |
| Success |
boolean |
Indicates whether the operation on the instance succeeded. Valid values: |
true |
Examples
Success response
JSON format
{
"RequestId": "xx-xx-xx-xx",
"KeyPairId": "ssh-xxx",
"KeyPairName": "test-kp",
"FailCount": 1,
"TotalCount": 3,
"Results": [
{
"Code": 200,
"InstanceId": "i-xxx",
"Message": "successful",
"Success": true
}
]
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | PublicKeyNotAttachWithInstance | Public Key Not Attach With Instance. | Public key not bound to instance |
| 400 | NoPermission | Permission denied. | |
| 400 | InvalidParameter.%s | The specified field %s invalid. Please check it again. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.