Skip to content

Track unused security groups of an AWS account over period of time with control of the interval to sample the security groups

License

Notifications You must be signed in to change notification settings

bridgecrewio/aws-collect-unused-security-groups

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Collect unused security groups of an aws account

A script to track unused security groups of an AWS account over period of time with control of the interval to sample the security groups usage. This script is useful when trying to detect usage of security groups by ephemeral resources

Table of contents

Setup

Configure aws sdk with the account to collect (~/.aws/credentials file) Run npm install

Execution

Run the script with your default configured AWS profile by running:

node CollectUnusedSecurityGroup.js

It will collect unused groups for one hour, and will re-sample the security groups for every 5 minutes.
To change the sampling parameters, refer:

Parameters:

 -p / -profile      The AWS profile to be used, as defined in the AWS credentials file
 -t / -time         The amount of time to run the script (in minutes)
 -i / -interval     The time interval to sample the unused security groups (in minutes)
 --no-default	    Skip groups named 'default', which are typically default VPC security groups, and can't be deleted

Running example:

node CollectUnusedSecurityGroup.js -p <aws_profile> -t <time_period> -i <interval_time> 

Output example json containing unused security groups over the entire period:

[
{
    "region": "us-east-1",
    "groupId": "sg-111",
    "groupName": "prod-rds"
  },
  {
    "region": "us-east-1",
    "groupId": "sg-2222",
    "groupName": "k8s-elb"
  },
  {
    "region": "us-east-1",
    "groupId": "sg-333",
    "groupName": "bastion-elb"
  },
  ...
]  

Note: Interval time units are in minutes

Contact

Created by Bridgecrew

About

Track unused security groups of an AWS account over period of time with control of the interval to sample the security groups

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published