A simple Python CLI tool to upload, delete, restore, and view files in an S3 bucket.
- Python (3.8+ recommended)
- pip (for installing Python packages)
- AWS Account with permissions to access the S3 bucket (see AWS documentation for setting up IAM users, access keys, etc.)
- (Optional) AWS CLI - not strictly required, but helpful for verification.
- Log in to your AWS Console.
- Go to IAM (Identity and Access Management).
- Create (or use) a user with the
AmazonS3FullAccess
policy (or a custom policy that at least allows reading/writing to the S3 bucket in question). - Generate Access Key ID and Secret Access Key for this user.
-
Clone or download this repository.
-
Create a
.env
file (or use.env-example
and rename it) in the project root with the following format:AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY AWS_REGION=us-east-1 S3_BUCKET_NAME=your-bucket-name LOCAL_BUCKET_PATH=bucket-path CLOUDFRONT_DISTRIBUTION_IDS=ID1,ID2
Replace with your actual credentials and bucket name. Keep the
.env
file secret. -
Install dependencies:
pip install -r requirements.txt
From the command line in the same directory as bucket_cli.py
, you can run:
-
Upload a single file:
python bucket_cli.py upload index.html
-
Delete a single file:
python bucket_cli.py delete index.html
-
Upload all files in the local bucket folder:
python bucket_cli.py upload .
-
Download all bucket files into the local bucket folder:
python bucket_cli.py restore .
Note: All bucket files will be in the LOCAL_BUCKET_PATH folder