Amazon AWS
AWS Cli tools Installation
Reference: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
- install AWS CLI version 2
AWS S3 commands
- After installation, test the AWS commands
- check your credentials
# aws configure list
- run the following command and enter the Access key and secret.
# aws configure
- Enter the AWS Access Key ID and AWS Secret Access Key and leave other blank
- AWS Access Key ID: ask your administrator
- AWS Secret Access Key: ask your administrator
- Default region name: Leave blank and Enter
- Default output format: Leave blank and Enter
- check your credentials again to see if it is success
# aws configure list
AWS S3 Sync commands
- sync desired bucket by AWS S3 Sync command
# aws s3 sync source target
- sync all files from a bucket to your local folder
- create an empty folder e.g. apao2021
- remember to put the source (s3 bucket) before your target (local folder)
# mkdir apao2021 # cd apao2021 # aws s3 sync s3://apao2021 .
- By default, the sync command will DOWNLOAD all newly uploaded files to your local folder when you run it. So, you may run it regularly to download new file, if any.
# cd apao2021 # aws s3 sync s3://apao2021 .
Please note that if you delete a file on your local folder, the next time you run the AWS S3 sync will download it again.
Troubleshooting
fatal error: An error occurred (IllegalLocationConstraintException) when calling the ListObjectsV2 operation: The ap-east-1 location constraint is incompatible for the region specific endpoint this request was sent to.
If failed, try change the region to 'ap-east-1' by running the 'aws configure' again.
- run the following command and enter the Access key and secret.
# aws configure
- Enter the AWS Access Key ID and AWS Secret Access Key and leave other blank
- AWS Access Key ID: ask your administrator
- AWS Secret Access Key: ask your administrator
- Default region name: input ap-east-1 and Enter
- Default output format: Leave blank and Enter