mianwu515 / rust-s3-cli

Rust based CLI tool for AWS S3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CI/CD Pipeline

AWS S3 Rust CLI Tool

The current AWS CLI is written in Python. For this project I have built a mini AWS S3 CLI using Rust which supports CRUD operations for buckets and objects.

image

Project Goals/Outcomes

  • Develop my first Rust project
  • Use Github Codespaces and Copilot
  • Integrate the 'AWS SDK for Rust' into a Rust project

Setup

  1. Create an AWS IAM User Policy for S3

  2. Configure your ~/.aws/credentials file with environment variables: aws_access_key_id, aws_secret_access_key and region

Useage

List all S3 buckets

$ cargo run list

List all objects in a specified S3 bucket

$ cargo run list --bucket <bucket_name>
# ex: cargo run list --bucket ids721

Create new S3 bucket

$ cargo run create --bucket <bucket_name>
# ex: cargo run create --bucket ids721

Upload an object to an S3 bucket

NB: Will create bucket if DNE

$ cargo run upload --bucket <bucket_name> --filepath <path_to_file>
# ex: cargo run upload --bucket ids721 --filepath ./test/test.png

Delete an object from an S3 bucket

$ cargo run delete --bucket <bucket_name> --key <object_key>
# ex: cargo run delete --bucket ids721 --key test.png

Delete an empty S3 bucket

$ cargo run delete --bucket <bucket_name>
# ex: cargo run delete --bucket ids721

CI/CD

Github Actions configured in .github/workflows/rust.yml

Build Executable

$ make release

Progress Log

  • Create an AWS IAM User Policy for S3
  • Configure Github Codespaces with AWS Toolkit Credential Profile
  • Initialise Rust project with AWS SDK for Rust
  • Establish basic AWS client connection to list S3 buckets
  • Add clap command line parsing for arguments (bucket name, local file name)
  • Bucket fxns: list, create new, check if exists, delete if empty
  • Object fxns: list objects in bucket, upload to existing bucket, upload to new bucket, delete
  • CI/CD with Github Actions

References

https://docs.rs/aws-sdk-s3/latest/aws_sdk_s3/client/struct.Client.html

About

Rust based CLI tool for AWS S3

License:Creative Commons Zero v1.0 Universal


Languages

Language:Rust 88.6%Language:Makefile 7.0%Language:Dockerfile 4.4%