A Rust command-line interface (CLI) application for managing Amazon S3 buckets and objects simply and elegantly.
- Bucket Management: List, create, and view configuration.
- Object Management: List, upload (with progress bar), delete, restore, and view attributes.
- Lifecycle Management: Manage lifecycle rules (transitions and expiration).
- Friendly Interface: Formatted output with colors and tables.
- Flexible Configuration: Support for AWS profiles and regions.
- Rust (cargo) installed.
- AWS credentials configured (via
aws configureor environment variables).
To build the project:
cargo build --releaseThe resulting binary will be located at target/release/s3sh.
The application can be run directly with cargo run or using the compiled binary.
-r, --region <REGION>: Specify the AWS region (e.g.,us-east-1).-p, --profile <PROFILE>: Specify the AWS profile to use.
List all buckets:
cargo run -- bucket listCreate a new bucket:
cargo run -- bucket create <bucket-name>
# Create with initial configuration
cargo run -- bucket create <bucket-name> --public true --versioning true --tags Env=DevView bucket configuration:
cargo run -- bucket config <bucket-name>Update bucket configuration:
# Make public (disable Block Public Access)
cargo run -- bucket update <bucket-name> --public true
# Enable versioning
cargo run -- bucket update <bucket-name> --versioning true
# Configure encryption (AES256 or aws:kms)
cargo run -- bucket update <bucket-name> --encryption AES256
# Add tags
cargo run -- bucket update <bucket-name> --tags Environment=Dev Project=S3shManage lifecycle rules for a bucket.
# Add a lifecycle rule
s3sh bucket lifecycle <bucket-name> \
--id <rule-id> \
--transitions '[{"days": 30, "storage_class": "STANDARD_IA"}]' \
--expiration 365
# Complex example with prefix and multiple transitions
cargo run -- bucket lifecycle my-test-bucket \
--id "archive-logs-rule" \
--prefix "logs/" \
--transitions '[
{"days": 30, "storage_class": "STANDARD_IA"},
{"days": 90, "storage_class": "GLACIER"}
]' \
--expiration 365Arguments:
--id: Unique identifier for the rule.--transitions: JSON array with transitions (e.g.,[{"days": 30, "storage_class": "STANDARD_IA"}]).--expiration: (Optional) Days for object expiration.--prefix: (Optional) Prefix to filter affected objects.--status: (Optional)trueto enable,falseto disable (default:true).
List objects in a bucket:
cargo run -- object list <bucket-name>Upload a file:
cargo run -- object upload <bucket-name> <path-to-file>
# Optionally specify a different key (S3 name):
cargo run -- object upload <bucket-name> <path-to-file> --key <destination-name>View object attributes:
cargo run -- object attributes <bucket-name> <object-key>Delete an object:
cargo run -- object delete <bucket-name> <object-key>Restore an object (from Glacier):
cargo run -- object restore <bucket-name> <object-key>The application uses the default AWS credential provider chain. It will look for credentials in this order:
- Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, etc.). - Configuration files (
~/.aws/credentials,~/.aws/config).
The project includes unit and integration tests. To run them:
cargo testIntegration tests are located in the tests/ directory and use mocks to simulate AWS S3 responses, so they do not require real credentials nor do they generate costs.