LeaveSecurityGroup

Last Updated: Mar 28, 2018

Description

Removes an instance from a specified security group. When you call this interface, consider the following:

  • To remove an instance from the security group, it must be in the Stopped or Running status.

  • Each instance must belong to at least one security group. If the instance only belongs to one security group and you try to remove it from this group, the request fails.

Request parameters

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

Response parameters

All parameters are common response parameters. For more information, see Common parameters.

Examples

Request example

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

Response 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. }

Error codes

Error code Error message HTTP status code Meaning
IncorrectInstanceStatus The current status of the resource does not support this operation. 403 Before being removed from a security group, the instance must be in the Stopped or Running status.
InstanceLastSecurityGroup The specified security group is the last security group for the instance. 403 Each instance must belong to at least one security group.
InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons. 403 The specified instance is locked, and the OperationLocks of the instance indicates "LockReason" : "security".
InstanceNotInSecurityGroup The instance not in the group. 403 The instance is not in the specified security group.
InvalidInstanceId.NotFound The specified InstanceId does not exist. 404 The specified InstanceId does not exist.
InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. 404 The specified SecurityGroupId does not exist.
Thank you! We've received your feedback.