A powerful CLI tool to manage S3 buckets across AWS, Cloudflare R2, and S3-compatible services
Project description
S3Hero ๐ฆธโโ๏ธ
A powerful CLI tool to manage S3 buckets across AWS S3, Cloudflare R2, and other S3-compatible services.
โจ Features
- ๐ชฃ Full Bucket Management - Create, list, delete, and empty buckets
- ๐ Object Operations - Upload, download, copy, move, and delete files
- ๐ Sync Support - Sync directories to/from S3 with progress tracking
- ๐ Multi-Provider Support - AWS S3, Cloudflare R2, MinIO, and any S3-compatible service
- ๐ค Profile Management - Multiple profiles for different accounts/providers
- ๐ Rich Output - Beautiful tables, trees, and progress bars
- ๐ Presigned URLs - Generate temporary access URLs
- ๐จ Bulk Operations - Empty buckets, recursive deletes, and more
๐ฆ Installation
Quick Install (Linux/macOS)
curl -fsSL https://raw.githubusercontent.com/aravindgopall/s3hero/main/scripts/install.sh | bash
Quick Install (Windows)
Open PowerShell as Administrator and run:
Set-ExecutionPolicy Bypass -Scope Process -Force
irm https://raw.githubusercontent.com/aravindgopall/s3hero/main/scripts/install.ps1 | iex
Install with pip
# Create and activate a virtual environment (recommended)
python3 -m venv ~/.s3hero/venv
source ~/.s3hero/venv/bin/activate # On Windows: ~/.s3hero/venv/Scripts/activate
# Install s3hero
pip install s3hero
Install from Source
# Clone the repository
git clone https://github.com/aravindgopall/s3hero.git
cd s3hero
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
Install via Homebrew (macOS/Linux)
# Add the tap
brew tap aravindgopall/tap
# Install s3hero
brew install s3hero
Or install directly from the formula:
brew install --build-from-source https://raw.githubusercontent.com/aravindgopall/s3hero/main/scripts/s3hero.rb
๐ Quick Start
1. Configure Your First Profile
s3hero configure add
This will guide you through setting up your S3 connection:
S3Hero Profile Setup
Profile name [default]: my-aws
Select S3 Provider:
1. AWS S3
2. Cloudflare R2
3. Other S3-Compatible
Provider [1]: 1
Access Key ID: AKIA...
Secret Access Key: ********
AWS Region [us-east-1]: us-west-2
2. List Your Buckets
s3hero bucket list
3. Upload Files
# Upload a single file
s3hero cp myfile.txt s3://my-bucket/myfile.txt
# Upload a directory
s3hero cp -r ./my-folder/ s3://my-bucket/folder/
๐ Usage Guide
Profile Management
# Add a new profile interactively
s3hero configure add
# Add a profile with command-line options
s3hero configure add \
--name production \
--provider aws \
--access-key AKIA... \
--secret-key ... \
--region us-east-1 \
--default
# List all profiles
s3hero configure list
# Show profile details (secrets are hidden)
s3hero configure show my-profile
# Set default profile
s3hero configure default my-profile
# Remove a profile
s3hero configure remove old-profile
Provider-Specific Setup
AWS S3
s3hero configure add \
--name aws-prod \
--provider aws \
--access-key YOUR_ACCESS_KEY \
--secret-key YOUR_SECRET_KEY \
--region us-east-1
Cloudflare R2
s3hero configure add \
--name cf-r2 \
--provider cloudflare_r2 \
--access-key YOUR_R2_ACCESS_KEY \
--secret-key YOUR_R2_SECRET_KEY \
--account-id YOUR_CLOUDFLARE_ACCOUNT_ID
Other S3-Compatible (MinIO, DigitalOcean Spaces, etc.)
s3hero configure add \
--name minio-local \
--provider other \
--access-key YOUR_ACCESS_KEY \
--secret-key YOUR_SECRET_KEY \
--endpoint https://minio.example.com \
--region us-east-1
Bucket Operations
# List all buckets
s3hero bucket list
s3hero bucket list --json # JSON output
# Create a bucket
s3hero bucket create my-new-bucket
s3hero bucket create my-bucket --region eu-west-1
# Delete a bucket (must be empty)
s3hero bucket delete my-bucket
# Force delete (empties bucket first)
s3hero bucket delete my-bucket --force
# Empty a bucket (delete all objects)
s3hero bucket empty my-bucket
s3hero bucket empty my-bucket --prefix logs/ # Only delete objects with prefix
# Get bucket size
s3hero bucket size my-bucket
# Check if bucket exists
s3hero bucket exists my-bucket
Object Operations
# List objects
s3hero ls s3://my-bucket
s3hero ls s3://my-bucket/prefix/
s3hero ls s3://my-bucket --tree # Tree view
s3hero ls s3://my-bucket --limit 100 # Limit results
s3hero ls s3://my-bucket --json # JSON output
# Upload files
s3hero cp local-file.txt s3://my-bucket/remote-file.txt
s3hero cp -r ./local-dir/ s3://my-bucket/remote-dir/
# Download files
s3hero cp s3://my-bucket/file.txt ./local-file.txt
s3hero cp s3://my-bucket/file.txt ./downloads/
# Copy between S3 locations
s3hero cp s3://bucket-a/file.txt s3://bucket-b/file.txt
# Move/rename objects
s3hero mv s3://my-bucket/old-name.txt s3://my-bucket/new-name.txt
# Delete objects
s3hero rm s3://my-bucket/file.txt
s3hero rm -r s3://my-bucket/folder/ # Recursive delete
s3hero rm -r -y s3://my-bucket/folder/ # Skip confirmation
# View object info
s3hero info s3://my-bucket/file.txt
# View file contents
s3hero cat s3://my-bucket/file.txt
# Generate presigned URL
s3hero presign s3://my-bucket/file.txt
s3hero presign s3://my-bucket/file.txt --expires 7200 # 2 hours
Sync Operations
# Sync local directory to S3
s3hero sync ./local/ s3://my-bucket/remote/
# Sync S3 to local directory
s3hero sync s3://my-bucket/remote/ ./local/
# Sync with delete (mirror)
s3hero sync --delete ./local/ s3://my-bucket/remote/
# Dry run (show what would happen)
s3hero sync --dry-run ./local/ s3://my-bucket/remote/
Using Different Profiles
# Use a specific profile for a command
s3hero -p production bucket list
s3hero --profile staging ls s3://my-bucket
# Set profile via environment variable
export S3HERO_PROFILE=production
s3hero bucket list
Output Formats
# Table format (default)
s3hero bucket list
# JSON format
s3hero bucket list --json
s3hero ls s3://my-bucket --json
# Tree view for objects
s3hero ls s3://my-bucket --tree
๐ง Configuration
Configuration is stored in ~/.s3hero/config.yaml:
default_profile: aws-prod
profiles:
- name: aws-prod
provider: aws
access_key: AKIA...
secret_key: ...
region: us-east-1
- name: cf-r2
provider: cloudflare_r2
access_key: ...
secret_key: ...
account_id: ...
region: auto
- name: minio
provider: other
access_key: ...
secret_key: ...
endpoint_url: https://minio.example.com
region: us-east-1
Environment Variables
| Variable | Description |
|---|---|
S3HERO_PROFILE |
Default profile to use |
S3HERO_INSTALL_DIR |
Custom installation directory |
S3HERO_VENV_DIR |
Custom virtual environment directory |
๐ ๏ธ Development
Setting Up Development Environment
# Clone and enter the repository
git clone https://github.com/aravindgopall/s3hero.git
cd s3hero
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install in development mode with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
ruff check src/
black --check src/
# Run type checking
mypy src/
Project Structure
s3hero/
โโโ src/
โ โโโ s3hero/
โ โโโ __init__.py # Package metadata
โ โโโ cli.py # CLI commands (Click)
โ โโโ client.py # S3 client wrapper
โ โโโ config.py # Configuration management
โ โโโ utils.py # Utilities and formatters
โโโ scripts/
โ โโโ install.sh # Linux/macOS installer
โ โโโ install.ps1 # Windows installer
โ โโโ uninstall.sh # Uninstaller
โ โโโ s3hero.rb # Homebrew formula
โโโ pyproject.toml # Project configuration
โโโ requirements.txt # Dependencies
โโโ README.md
๐ฆ Publishing to PyPI
# Build the package
pip install build
python -m build
# Upload to PyPI
pip install twine
twine upload dist/*
๐บ Publishing to Homebrew
Create a Homebrew Tap
- Create a GitHub repository named
homebrew-tap - Copy
scripts/s3hero.rbtoFormula/s3hero.rbin your tap - Update the formula with correct SHA256 checksums:
# Get SHA256 for release tarball
curl -sL https://github.com/aravindgopall/s3hero/archive/refs/tags/v1.0.0.tar.gz | shasum -a 256
- Users can then install with:
brew tap aravindgopall/tap
brew install s3hero
๐๏ธ Uninstallation
Linux/macOS
# Using uninstall script
curl -fsSL https://raw.githubusercontent.com/aravindgopall/s3hero/main/scripts/uninstall.sh | bash
# Or manually
rm -rf ~/.s3hero ~/.local/bin/s3hero
Windows
# Remove installation
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\s3hero"
# Remove from PATH (open System Properties > Environment Variables)
Homebrew
brew uninstall s3hero
brew untap aravindgopall/tap
pip
pip uninstall s3hero
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
Made with โค๏ธ by the S3Hero Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file s3hero-1.0.0.tar.gz.
File metadata
- Download URL: s3hero-1.0.0.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91c48940253f230111db83fd1b096840a33fc57cc926840c9cc9c6e1e4f6feb2
|
|
| MD5 |
d690a36884897f4637c9199cd8daa9dc
|
|
| BLAKE2b-256 |
9449680e90163540f75d3fcf615379680919267f12b947e587a5f272503dab3a
|
File details
Details for the file s3hero-1.0.0-py3-none-any.whl.
File metadata
- Download URL: s3hero-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
493a9c13eb130c85f316a7647622a170e5b61ca984f5f467e78cbb772db4a3fc
|
|
| MD5 |
a0f450ccfe30a349068bfa73170e8985
|
|
| BLAKE2b-256 |
91f14af89f7c0c17810d165d5f7936b33ad1d324f13f0b44fa0da4ab51853c55
|