All Products
Search
Document Center

Elastic Compute Service:DeleteSecurityGroup

更新時間:Dec 23, 2024

Deletes a security group and all security group rules in the security group.

Operation description

  • Make sure that no Elastic Compute Service (ECS) instances exist in the security group. You can query instances by calling the DescribeInstances operation.
  • Make sure that no elastic network interfaces (ENIs) exist in the security group. You can query ENIs by calling the DescribeNetworkInterfaces operation.
  • Make sure that the security group that you want to delete is not referenced by rules of other security groups. You can query the associations by calling the DescribeSecurityGroupReferences operation.
  • If the InvalidOperation.DeletionProtection error code is returned when you call the DeleteSecurityGroup operation to delete a security group, 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 the Disable deletion protection for a security group section of the "Configure and manage security groups for an ACK cluster" topic.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:DeleteSecurityGroupdelete
*SecurityGroup
acs:ecs:{#regionId}:{#accountId}:securitygroup/{#securitygroupId}
    none
none

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 changedView Change Details