All Products
Search
Document Center

Elastic Compute Service:DeleteSecurityGroup

Last Updated:Mar 19, 2024

Deletes a security group.

Operation description

  • Before you delete a security group, make sure that the security group does not contain instances and is not referenced by other security groups. Otherwise, the DeleteSecurityGroup request fails. You can call the DescribeSecurityGroupReferences operation to query the reference details of the security group.
  • If the error code InvalidOperation.DeletionProtection is returned when you call the DeleteSecurityGroup operation to delete a security group or if a deletion protection-related message appears when you delete a security group in the console, the deletion protection feature is enabled for the security group. When you create a Container Service for Kubernetes (ACK) cluster, the deletion protection feature is enabled for an associated security group to prevent accidental deletion. You cannot manually disable the deletion protection feature for the security group. The deletion protection feature can be automatically disabled only after the ACK cluster is deleted. For more information, see Disable deletion protection for a security group

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

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

cn-hangzhou
SecurityGroupIdstringYes

The security group ID. You can call the DescribeSecurityGroups operation to query the security group ID.

sg-bp1fg655nh68xyz9****

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400MissingParameter.RegionIdThe parameter "RegionId" should not be null.-
401InvalidOperation.SecurityGroupNotAuthorizedThe specified security group is not authorized to operate.You do not have permission to operate the current security group.
403DependencyViolationThere is still instance(s) in the specified security group.The security group contains instances. Remove the instances from the security group and try again.
403DependencyViolationThe specified security group has been authorized in another one.The specified security group is referenced by another security group and cannot be deleted.
403InvalidOperation.ResourceManagedByCloudProduct%sYou cannot modify security groups managed by cloud services.
404InvalidSecurityGroup.NotFoundThe specified security group is not found.The specified security group could not be found
500InternalErrorThe request processing has failed due to some unknown error.An internal error has occurred. Try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-01-03The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 500
    Added Error Codes: 401
    Added Error Codes: 404