General configuration
aws configure
AWS Access Key ID [None]: Q3AM3UQ867SPQQA43P2F
AWS Secret Access Key [None]: zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG
Default region name [None]: us-east-1
Default output format [None]: ENTER
S3
# enable AWS Signature Version'4' (minio need)
aws configure set default.s3.signature_version s3v4
# paramater if not use a aws S3 stroage
aws --endpoint-url https://s3.host s3 [command]
# list buckets
aws s3 ls
# list files in bucket
aws s3 ls <S3Uri>
# create bucket
aws s3 mb <S3Uri>
# delete bucket
aws s3 rb <S3Uri>
# copy (upload/download) file
aws s3 cp <LocalPath> <S3Uri> or <S3Uri> <LocalPath> or <S3Uri> <S3Uri>
aws s3 cp example.tar.gz s3://mybucket
# When passed with the parameter --recursive, the following cp command
# recursively copies all files under a specified directory to a specified
# bucket and prefix while excluding some files by using an --exclude
# parameter. In this example, the directory myDir has the files test1.txt
# and test2.jpg:
aws s3 cp myDir s3://mybucket/ --recursive --exclude "*.jpg"
aws s3 cp s3://mybucket/ s3://mybucket2/ --recursive --exclude "another/*"
# You can combine --exclude and --include options to copy only objects
# that match a pattern, excluding all others
aws s3 cp s3://mybucket/logs/ s3://mybucket2/logs/ --recursive --exclude "*" --include "*.log"
# Setting the Access Control List (ACL) while copying an S3 object
# paramaters (https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl):
# private, public-read, public-read-write, authenticated-read, aws-exec-read,
# bucket-owner-read, bucket-owner-full-control and log-delivery-write
aws s3 cp s3://mybucket/test.txt s3://mybucket/test2.txt --acl public-read-write
# move file
aws s3 mv <LocalPath> <S3Uri> or <S3Uri> <LocalPath> or <S3Uri> <S3Uri>
# delete file
aws s3 rm <S3Uri>
aws s3 rm s3://mybucket/example.tar.gz
# sync directory
# Syncs directories and S3 prefixes. Recursively copies new and updated
# files from the source directory to the destination. Only creates folders
# in the destination if they contain one or more files.
aws s3 sync <LocalPath> <S3Uri> or <S3Uri> <LocalPath> or <S3Uri> <S3Uri> [--delete]
# --delete (boolean): Files that exist in the destination but not in the
# source are deleted during sync.
Reference: https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#cli-aws-s3