Table of Contents
AWS CLI tool for command line usage
AWS CLI is a common tool allowing to control S3 service. AWS CLI tool is written in python.
AWS CLI installation
To install AWS CLI we recommend using official AWS docummentation. There you can find the guide on how to install AWS CLI on Linux and Windows as well.
Configuration of AWS CLI
In the following, we will demonstrate the AWS CLI configuration. Following exemplary commands utilize the --profile option.
aws configure --profile test_user AWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxxxxx AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Default region name [None]: us-east-1 Default output format [None]: text
AWS Access Key ID - access key, obtained from data storage administrator
Secret Access Key - secret key, obtained from data storage administrator
Default region name - Here isert "us-east-1"!
Default output format - choose the output format (json, text, table)
Controls of AWS CLI - high-level (s3)
To show the help (available commands) you can use help. aws s3 tool allows you to use several advanced functions, see below.
aws s3 help
<hidden Operations with Buckets>
Bucket creation
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz mb s3://test1
Bucket listing
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz ls 2019-09-18 13:30:17 test1
Bucket deletion
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz rb s3://test1
</hidden>
<hidden Operation with files>
Files
File upload
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz cp C:/Users/User/Desktop/test_file.zip s3://test1 upload: Desktop\test_file.zip to s3://test1/test_file.zip
File download
$ aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz cp s3://test1/test_file.zip C:\Users\User\Downloads\ download: s3://test1/test_file.zip to Downloads\test_file.zip
File deletion
$ aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz rm s3://test1/test_file.zip delete: s3://test1/test_file.zip
</hidden>
<hidden Directory/Folders operations>
Directories
Upload the directory
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz cp C:\Users\User\Desktop\test_dir s3://test1/test_dir/ --recursive
Directory download
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz cp s3://test1/test_dir C:\Users\User\Downloads\test_dir\ --recursive
Directory deletion
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz rm s3://test1/test_dir --recursive
Directory sync
Directory sync to the S3 storage
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz sync C:\Users\User\Desktop\test_sync s3://test1/test_sync/
Directory sync from the S3 storage to local PC
aws s3 --profile test_user --endpoint-url https://s3.cl2.du.cesnet.cz sync s3://test1/test_sync/ C:\Users\User\Downloads\test_sync
</hidden>
Controls of AWS CLI - api-level (s3api)
aws tool allows the usage of aws s3api module. This module provides advanced functions to control S3 service, see below. The configuration of credentials and connections is the same like for aws in the beginning of this guide
The set of available commands can be obtained by the following command with the option help. Alternatively is the complete list available in the AWS website.
Exeplary configuration file for aws tool
After successful configuration, the configuration file should be created. You can find the example below. You can find the credentials file in the same path.
Windows: C:/Users/User/.aws/config Linux: /home/user/.aws/config [profile test-user] region = us-east-1 output = text