This topic describes how to call the DeleteSecurityGroup operation by using Alibaba Cloud CLI to delete a security group.

Background information

You can call the DeleteSecurityGroup operation to delete a security group. We recommend that you read the description of the operation before you call the operation. For more information, see DeleteSecurityGroup.

When you call an API operation through Alibaba Cloud CLI, make sure that request parameter values of different data types are in required formats. For more information, see Parameter format overview.

Request examples

  1. Call the DescribeSecurityGroups operation to query the ID of the security group that you want to delete.

    In this example, the security group name namedemo is used to query the ID of the security group.

    aliyun ecs DescribeSecurityGroups --RegionId cn-hangzhou --SecurityGroupName namedemo --DryRun false --output cols=SecurityGroupId rows=SecurityGroups.SecurityGroup[]
    Sample response:
    SecurityGroupId
    ---------------
    sg-bp1i4c0xgqxadew2****
  2. Delete the sg-bp1i4c0xgqxadew2**** security group.
    aliyun ecs DeleteSecurityGroup --RegionId cn-hangzhou --SecurityGroupId sg-bp1i4c0xgqxadew2****

Result

{
        "RequestId": "B0B04008-0685-4EC8-9468-F2FB44981FA7"
}