Remove an instance from a security group

Last Updated: Jul 25, 2017

Description

When removing an instance from a specified security group, consider the following:

  • This operation can only be performed on instances in Stopped or Running status.
  • Each instance must belong to at least 1 security group. If an instance only belongs to one security group and you try to remove it from this group, the request will fail.

Request parameters

Name Type Required Description
Action String Yes Value: LeaveSecurityGroup.
InstanceId String Yes The specified instance ID.
SecurityGroupId String Yes The security group ID.

Return parameters

All parameters are public return parameters. For details, refer to Public Return Parameters.

Error code

Error Code Description Http status code Meaning
InvalidInstanceId.NotFound The specified InstanceId does not exist. 404 The specified InstanceId does not exist.
MissingParameter The input parameter InstanceId that is mandatory for processing this request is not supplied. 400 InstanceId value is missing.
InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. 404 The specified SecurityGroupId does not exist.
MissingParameter The input parameter SecurityGroupId that is mandatory for processing this request is not supplied. 400 SecurityGroupId value is missing.
InstanceLastSecurityGroup The specified security group is the last security group for the instance. 403 This is the only security group for the instance.
IncorrectInstanceStatus The current status of the resource does not support this operation. 403 The current status of the resource does not support this operation.
InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons. 403 The operation is denied because the resource is locked for security reasons.

Examples

Request example

  1. https://ecs.aliyuncs.com/?Action=LeaveSecurityGroup
  2. &InstanceId=i-instance1
  3. &SecurityGroupId=F876FF7BA984
  4. &<Public Request Parameters>

Return example

XML format

  1. <LeaveSecurityGroupResponse>
  2. <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
  3. </LeaveSecurityGroupResponse>

JSON format

  1. {
  2. "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
  3. }
Thank you! We've received your feedback.