nchika
Posted on February 4, 2024
Why I Created s3hub
When building AWS resources with CloudFormation, I often find myself needing to check the contents of S3 buckets. How do you typically check the contents of S3 buckets? Personally, I'm not fond of the AWS Management Console (GUI), and I find the AWS CLI somewhat cumbersome.
It's a bad habit of mine, but I tend to create tools to solve problems. The tool I've created this time is named s3hub, and its main feature is its interactive mode.
Features
The s3hub command provides following features:
- Create a S3 bucket
- List S3 buckets
- List S3 objects in the S3 bucket
- Copy files to S3 bucket
- Delete contents from the S3 bucket
- Delete the S3 bucket
- Interactive mode
How to install
go install github.com/nao1215/rainbow/cmd/s3hub@latest
How to use
The s3hub command allows you to specify a profile as an option, but it is more user-friendly to use the AWS_PROFILE
environment variable. S3hub operates without requiring the 's3://' protocol to be added to the bucket name.
Create a bucket(s)
s3hub mb ${YOUR_BUCKET_NAME}
List buckets
s3hub ls
List contents of a bucket
s3hub ls ${YOUR_BUCKET_NAME}
Copy files to a bucket
From local to S3:
s3hub cp ${YOUR_FILE_PATH} s3://${YOUR_BUCKET_NAME}
From S3 to local:
s3hub cp s3://${YOUR_BUCKET_NAME} ${YOUR_FILE_PATH}
Delete a object from a bucket
If you want to delete a specific object, use the following command:
s3hub rm ${CONTENT_PATH_IN_BUCKET}/${S3_KEY}
If you want to delete all contents in a bucket, use the wildcard:
s3hub rm ${YOUR_BUCKET_NAME}/*
Delete a bucket with objects
When the number of S3 objects is large, we parallelize the deletion process to enhance speed.
s3hub rm --recursive ${YOUR_BUCKET_NAME}
s3hub is Part of the Rainbow Project
I use AWS for work, and I plan to develop numerous tools to make development with AWS easier. I thought "rainbow" would be a fitting name for the repository that manages multiple tools. I borrowed it from my favorite band, Ritchie Blackmore's Rainbow (I'm 33 years old, but I love this band).
I plan to continue developing many tools in the future, so if you're interested, please support me with GitHub Star and such. GitHub Stars are a great way to boost developers' motivation for free.
The Rainbow Project incurs costs because it utilizes AWS. For those who are willing to provide financial support, please consider supporting us through GitHub Sponsors. We would be deeply grateful and appreciative.
Posted on February 4, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.