How to Remove Unused Security Groups in AWS
Learn how to identify and delete unused security groups in AWS. Follow our guide to keep your AWS environment clean and secure.
Learn how to identify and delete unused security groups in AWS. Follow our guide to keep your AWS environment clean and secure.
If you want to maintain excellent resource management in AWS, you should regularly find and remove unused resources like security groups.
In your account, you could have security groups that were created for specific purposes, and are now outdated, or groups that were disassociated from other resources and forgotten. While there isn't a direct recurring cost for having excess security groups, it adds unnecessary attack surface and clutter to your AWS account.
In this guide, we'll show you the steps to find unused security groups and remove them.
If the security group has no associated instances, load balancers, and network interfaces, it's an unused security group, and you can safely remove it.
Before removing a security group, you can check if it has any associated resources or dependencies using either the AWS Console or AWS CLI.
You can check for dependent resources by using the following command:
The output will show you all associated load balancers, network interfaces, and instances in the Attachments output.
If there are no associated resources, then you can safely delete it.
This method we just showed is good for individual groups, but what if you want to find all security groups in your AWS account that are unused?
Here’s how to search for unused security groups in AWS using the Console and CLI.
This command will extract and display the unused security group names from the list.
You can replace the jq parameter in the command with specific names to view only your desired unused security groups.
Here’s how to remove unused security groups in AWS using the Console and CLI:
Replace the Values=group-name parameter with the name of the unused security group you want to remove.
To delete multiple unused security resources at one-time type the command:
This will check the number of associated resources with the security groups and only delete the unused ones.
You can run through the steps we just covered, but with all the different AWS offerings, cleaning up unused resources takes significant time and context-switching.
Instead of manually running checks, there’s an easier way to manage your resources and ensure a clean AWS account.
With Blink, there’s an easier way to manage all of your resources and ensure a clean AWS account.
This automation in the Blink library scans your AWS account for unused ACLs and Security Groups.
When the automation runs, it does the following steps:
You can also customize this automation by dragging and dropping no-code actions into the canvas to add conditional logic, notifications, or approval steps.
Build your own automation from scratch or use one of our 5K pre-built automations like this one today.
Get started with Blink today to see how easy automation can be.
Blink is secure, decentralized, and cloud-native. Get modern cloud and security operations today.