go-aws-storage
(local) usage of AWS S3 via Cobra and/or AWS CLI.
- create bucket via AWS CLI
aws s3api create-bucket --bucket my-bucket --endpoint-url http://localhost:4566 --profile localstack
go run main.go --config=config.yaml create-bucket --name=my-bucket [--public=true]
aws s3api list-buckets --endpoint-url http://localhost:4566 --profile localstack
go run main.go --config=config.yaml list-buckets
aws s3api put-object --bucket my-bucket --key sample.png --body sample.png \
--endpoint-url http://localhost:4566 --profile localstack
go run main.go put-objects --bucket=my-bucket --key=sample_1.png --key=sample_2.png
aws s3api list-objects --bucket my-bucket --endpoint-url http://localhost:4566 --profile localstack
go run main.go --config=config.yaml list-objects --bucket=my-bucket
aws s3api get-object --bucket my-bucket --key sample.png new-sample.png \
--endpoint-url http://localhost:4566 --profile localstack OUT_FILENAME
go run main.go get-object --config=config.yaml --bucket=my-bucket --key=sample.png --path=.
aws s3 presign s3://BUCKET/KEY --endpoint-url http://localhost:4566 --profile localstack
go run main.go assign-url --config=config.yaml --bucket=my-bucket --key=sample.png
- delete object via AWS CLI
aws s3api delete-object --bucket my-bucket --key sample.png --endpoint-url http://localhost:4566 --profile localstack
go run main.go delete-object --config=config.yaml --bucket=my-bucket --key=sample.png
- delete bucket via AWS CLI
aws s3api delete-bucket --bucket my-bycket --endpoint-url http://localhost:4566 --profile localstack
go run main.go delete-bucket --config=config.yaml --bucket=my-bucket
※ References: