Find S3 buckets that are not managed by active CloudFormation stacks (orphaned buckets) and purge them.
Use cases:
- You are using Infrastructure as Code (e.g. AWS CDK, CloudFormation) and opted for the default
RetentionPolicy=Retain
, which steers on the side of caution and leaves behind orphaned S3 buckets, after their corresponding CloudFormation stack is deleted. This is fine for production environments, where data retention is important, but bad for development or QA environments, that are recreated often, leaving behind lots of junk S3 buckets.
git clone [email protected]:Dzhuneyt/nuke-orphan-buckets.git && cd nuke-orphan-buckets
- Run it:
go run .
- Optionally provide the AWS region or other optional parameters, respected by the AWS CLI:
AWS_REGION=eu-west-2 go run .