Guideline states that unused EC2 security groups should be removed to enhance security.
Rule | Unused EC2 security groups should be removed |
Framework | PCI v3.2.1 |
Severity | ✔ Low |
Rule Description:
Unused EC2 security groups should be removed for PCI v3 compliance. This rule ensures that any security groups associated with your EC2 instances that are no longer in use are deleted. Unused security groups pose a potential security risk as they may have unnecessary open ports or overly permissive rules.
Troubleshooting Steps:
If you encounter issues while removing unused EC2 security groups, follow these troubleshooting steps:
Necessary Codes:
The following AWS CLI command can be used to list all the unused security groups:
aws ec2 describe-security-groups --query 'SecurityGroups[?length(Instances)==`0`]'
Step-by-Step Guide for Remediation:
Follow these steps to remove unused EC2 security groups:
aws ec2 delete-security-group --group-id <security-group-id>
Replace
<security-group-id>
with the actual ID of the security group you want to remove. Repeat this command for each security group you wish to delete.
5. Verify deletion: Execute the AWS CLI command below to ensure successful removal of the security group(s):aws ec2 describe-security-groups --group-ids <security-group-id>
Replace
<security-group-id>
with the ID of the removed security group. If the command returns an error, it indicates that the security group was successfully deleted.
6. Repeat steps 4-5: Repeat steps 4 and 5 for each additional security group you want to remove.
7. Validate rule compliance: After removing the unused security groups, ensure that your environment is still functioning correctly and all required resources are accessible.