LeaveSecurityGroup
Removes an ECS instance or an Elastic Network Interface (ENI) from a specified security group.
Operation description
This API operation is deprecated. Call ModifyInstanceAttribute to add or remove an ECS instance from a security group, or call ModifyNetworkInterfaceAttribute to add or remove an Elastic Network Interface (ENI) from a security group.
You cannot remove an instance and an Elastic Network Interface (ENI) from a security group at the same time. Specifically, you cannot specify both the InstanceId and NetworkInterfaceId parameters.
Before you remove an instance from a security group, the instance must be in the Stopped or Running state.
An instance or Elastic Network Interface (ENI) must be added to at least one security group. If the instance or Elastic Network Interface (ENI) is added to only one security group, the removal request fails and returns an error.
If you remove an instance or network interface controller (NIC) that is not in the security group, the removal request fails and returns an error.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:LeaveSecurityGroup |
update |
Instance
*SecurityGroup
NetworkInterface
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| SecurityGroupId |
string |
Yes |
The ID of the security group. |
sg-bp67acfmxazb4p**** |
| InstanceId |
string |
No |
The instance ID. Note
If you specify this parameter, you must leave NetworkInterfaceId empty. |
i-bp67acfmxazb4p**** |
| NetworkInterfaceId |
string |
No |
The ID of the network interface controller (NIC). Note
If you specify this parameter, you must leave InstanceId empty. |
eni-bp13kd656hxambfe**** |
| RegionId |
string |
No |
The region ID. You can call the DescribeRegions operation to query the most recent region list.
|
cn-hangzhou |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
Examples
Success response
JSON format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidInstanceId.Malformed | The specified parameter "InstanceId" is not valid. | |
| 400 | MissingParameter.RegionId | The specified RegionId should not be null. | The RegionId parameter is required. |
| 400 | InvalidOperation.InvalidEniState | %s | The current status of the ENI does not support this operation. |
| 400 | InvalidSecurityGroupAssociation.NotFound | %s. | The specified ECS or ENI is not associated with the specified security group. |
| 403 | InstanceLastSecurityGroup | The specified security group is the last security group for the instance. | The specified security group is the only security group to which the instance belongs. |
| 403 | IncorrectInstanceStatus | The current status of the resource does not support this operation. | |
| 403 | InstanceLockedForSecurity | The specified operation is denied as your instance is locked for security reasons. | The instance to which the disk is attached is locked for security reasons. |
| 403 | InstanceNotInSecurityGroup | The instance not in the group. | |
| 403 | InvalidOperation.ResourceManagedByCloudProduct | %s | You cannot modify security groups managed by cloud services. |
| 403 | InvalidOperation.AtLeastInOneGroup | %s | The specified resource must be added to at least one security group. If the specified resource is added to only one security group, the call fails and this error code is returned. |
| 403 | InvalidOperation.EniServiceManaged | %s | The operation is invalid. |
| 403 | InvalidOperation.InvalidEniType | %s | This operation is not allowed for the current network interface type. |
| 403 | InvalidParam.Malformed | %s | Invalid parameter |
| 403 | InvalidParam.EniIdAndInstanceId.Conflict | %s | The InstanceId and NetworkInterfaceId parameters are mutually exclusive and cannot be both specified. |
| 404 | InvalidInstanceId.NotFound | The specified InstanceId does not exist. | The specified instanceId is invalid. |
| 404 | InvalidSecurityGroupId.NotFound | The specified SecurityGroupId does not exist. | The specified security group does not exist in this account. Check whether the security group ID is correct. |
| 404 | InvalidEniId.NotFound | %s | |
| 404 | InvalidVSwitchId.NotFound | The specified virtual switch %s does not exist. | The specified switch does not exist. |
| 504 | RequestTimeout | The request encounters an upstream server timeout. | |
| 409 | InvalidOperation.Conflict | Request was denied due to conflict with a previous request, please try again later. | This operation is not allowed due to a task conflict. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.