aws ec2 delete-security-group
Deletes a security group. AWS CLI reference
2 examples 3 options Its page in the AWS CLI reference
Examples
Example 1: To delete a security group (EC2-Classic)
The following delete-security-group example deletes the security group named MySecurityGroup.
aws ec2 delete-security-group --group-name MySecurityGroupIdentify--group-name[Default VPC] The name of the security group.Its output
{
"Return": true,
"GroupId": "sg-1a2b3c4d"
}For more information, see Delete an Amazon EC2 security group in the Amazon EC2 User Guide.
Example 2: To delete a security group (EC2-VPC)
The following delete-security-group example deletes the security group with the ID sg-903004f8. Note that you can't reference a security group for EC2-VPC by name.
aws ec2 delete-security-group --group-id sg-903004f8Identify--group-idThe ID of the security group.Its output
{
"Return": true,
"GroupId": "sg-903004f8"
}For more information, see Delete an Amazon EC2 security group in the Amazon EC2 User Guide and Creating, configuring, and deleting Amazon EC2 security groups in the AWS CLI in the AWS CLI User Guide.
Options
--dry-runChecks whether you have the required permissions for the action, without actually making the request, and provides an error response.--group-idThe ID of the security group.--group-name[Default VPC] The name of the security group.