Deleting a Security Group

You can delete a custom security group that is no longer used for any instance or in any security group rule, and that does not contain any rule.

You cannot delete default security groups.

Deleting a Security Group Using Cockpit

Before you begin: Ensure that the security group you want to delete:

  1. Click Network/Security > Security Groups.

  2. Click the security group you want to delete.

    Multiselection is available.

    The security group is selected.

  3. Click Delete .
    A confirmation dialog box appears.

  4. Click Delete to validate.
    The security group is deleted and no longer appears on the Security Groups page.

Deleting a Security Group Using AWS CLI

Before you begin: Ensure that the security group you want to delete:

To delete a security group, use the delete-security-group command following this syntax:

Request sample
$ aws ec2 delete-security-group \
    --profile YOUR_PROFILE \
    --group-id sg-12345678 \
    --group-name my-security-group \

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • (optional) group-id: The ID of the security group.

  • (optional) group-name: The name of the security group.

    • In a Virtual Private Cloud (VPC), you need to specify the group-id attribute.

    • In the public Cloud, you can specify the group-id or the group-name attribute.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The specified security group is deleted.

Related Pages

Corresponding API Method

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.