Simple script to detect AWS stale Security Groups.

Simple script to detect AWS stale Security Groups.


Related discussions:

Cool! I’d consider making it a lambda function and integrating it with AWS Config alerting.

What’s the logic if it’s stale or not?

Looking at the code, any SGs that are not associated with an EC2 instance, ENI, ELB, ALB, RDS or redshift instance.

Great idea I might have a go at that myself. I’ve been meaning to find an excuse to use it and learn it.

couple of thoughts:

  1. All security groups in use would be attached to ENIs? As such skipping RDS and EC2 scans would work fine?
  2. Pagination support, boto3 has limits to what it returns in a single call.

I like it overall though. Clean code.

Support pagination and I could see using this.