This project is a Go application designed to delete AWS S3 buckets. It retrieves the list of buckets from your AWS account and performs cleanup operations on specified buckets.
- Go 20 and higher.
- AWS account with IAM priviledges to perform S3 operations.
- List all S3 buckets in your AWS account.
- Delete specified S3 buckets and its Objects.
- Works with Versioned and Non-Versioned buckets.
- Utilize GO concurrency for delete operations.
- Clone the repository:
git clone https://github.com/pratikkumar-mohite/s3-cleaner.git
- Navigate to the project directory:
cd s3-cleaner
- Build the application:
make build
- Move the binary to executable path
mv s3-cleaner /usr/local/bin/
As of now the actual test are not there because we dont have s3 mock apis to mimic the s3 object behaviour specifically in go, this project has dependency on S3Mock project to enable the go test
.
There is an alternative to test the application with actual AWS S3 bucket with s3-cleaner.
- Perform the above Build stage
- Create test directory
mkdir -p test/files
- Create dummy files
dd if=/dev/urandom of=test/files/file1.txt count=100 bs=1M dd if=/dev/urandom of=test/files/file2.txt count=100 bs=1M
- Export AWS_UPLOAD_TEST_FILES
export AWS_UPLOAD_TEST_FILES=true
- Run the application
make run
This will upload file1.txt
and file2.txt
to S3 bucket and then perform S3 object + bucket cleanup.
- Ensure you have AWS credentials configured. You can set them up using the AWS CLI(ignore if already set):
aws configure --profile <your-aws-profile>
- Setup Environment variables
export AWS_REGION=us-east-1 export AWS_DELETE_S3_BUCKET=pratikkumar-mohite-test export AWS_PROFILE=pratikkumar-mohite-aws
- Run the application:
s3-cleaner
Contributions are greatly appreciated. We actively manage the issues list, and try to highlight issues suitable for newcomers. The project follows the typical GitHub pull request model. Before starting any work, please either comment on an existing issue, or file a new one.