Skip to main content

A powerful CLI tool to manage S3 buckets across AWS, Cloudflare R2, and S3-compatible services

Project description

S3Hero ๐Ÿฆธโ€โ™‚๏ธ

Python 3.8+ License: MIT

A powerful CLI tool to manage S3 buckets across AWS S3, Cloudflare R2, and other S3-compatible services.

S3Hero Demo

โœจ 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

  1. Create a GitHub repository named homebrew-tap
  2. Copy scripts/s3hero.rb to Formula/s3hero.rb in your tap
  3. 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
  1. 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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • boto3 - AWS SDK for Python
  • Click - CLI framework
  • Rich - Beautiful terminal formatting

Made with โค๏ธ by the S3Hero Team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3hero-1.0.0.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s3hero-1.0.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

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

Hashes for s3hero-1.0.0.tar.gz
Algorithm Hash digest
SHA256 91c48940253f230111db83fd1b096840a33fc57cc926840c9cc9c6e1e4f6feb2
MD5 d690a36884897f4637c9199cd8daa9dc
BLAKE2b-256 9449680e90163540f75d3fcf615379680919267f12b947e587a5f272503dab3a

See more details on using hashes here.

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

Hashes for s3hero-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 493a9c13eb130c85f316a7647622a170e5b61ca984f5f467e78cbb772db4a3fc
MD5 a0f450ccfe30a349068bfa73170e8985
BLAKE2b-256 91f14af89f7c0c17810d165d5f7936b33ad1d324f13f0b44fa0da4ab51853c55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page