Deletes a security group.

Description

Before you delete a security group, make sure that no instances are present in the security group and that the security group is not referenced by other security groups DescribeSecurityGroupReferences). Otherwise, the DeleteSecurityGroup request fails.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DeleteSecurityGroup

The operation that you want to perform. Set the value to DeleteSecurityGroup.

RegionId String Yes cn-hangzhou

The region ID of the security group. You can call the DescribeRegions operation to query the most recent region list.

SecurityGroupId String Yes sg-bp1fg655nh68xyz9****

The ID of the security group. You can call the DescribeSecurityGroups to query the most recent list of security group IDs.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The ID of the request.

Examples

Sample requests

http(s)://ecs.aliyuncs.com/?Action=DeleteSecurityGroup
&RegionId=cn-hangzhou
&SecurityGroupId=sg-bp1fg655nh68xyz9****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DeleteSecurityGroupResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</DeleteSecurityGroupResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

Error codes

HTTP status code Error code Error message Description
403 DependencyViolation There is still instance(s) in the specified security group. The error message returned because instances are present in the security group. Remove the instances and try again.
403 DependencyViolation The specified security group has been authorized in another one. The error message returned because the specified security group is referenced by another security group.
403 InvalidOperation.ResourceManagedByCloudProduct %s The error message returned because you cannot delete security groups managed by cloud services.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred. Try again later. If the error persists, submit a ticket.

For a list of error codes, visit the Error Center.