AWS CLI
AWS CLI (AWS Command Line Interface) is a command line interface for working with AWS services.
Customize the AWS CLI
Set up access
Access can be configured by a user with role Account Owner or User Administrator.
- Create a service user с a role with access to object storage. If you are using a user with the Object Storage User role, the container must be configured with the access policy.
- Issue an S3 key to the user.
Install the client
Use the instructions Install or update to the latest version of the AWS CLI Amazon documentation.
Create an AWS CLI configuration
-
Open the terminal.
-
Open the configuration mode:
aws configure
-
Enter
AWS Access Key ID
— field value Access key from S3 key. -
Enter
AWS Secret Access Key
— field value Secret key from the S3 key. -
Enter
Default region name
— pool, in which the object store is located (e.g.,ru-1
). -
Enter
Default output format
or leave it blank. -
The settings will be saved in the configuration files:
-
accounting data in
.aws/credentials
:[default]
aws_access_key_id = <access_key>
aws_secret_access_key = <secret_key> -
default pool in
.aws/config
:[default]
region = <pool>
-
Install the certificate
Linux/macOS
Windows
-
Create a folder
~/.selectels3/
:mkdir -p ~/.selectels3/
-
Download the certificate and place it in the folder
~/.selectels3/
:wget https://secure.globalsign.net/cacert/root-r6.crt -O ~/.selectels3/root.crt
openssl x509 -inform der -in ~/.selectels3/root.crt -out ~/.selectels3/root.crt
chmod 600 ~/.selectels3/root.crt -
In the configuration file
.aws/config
add a parameter:ca_bundle = ~/.selectels3/root.crt
-
Create a text file — for example,
root.txt
. -
In the file.
root.txt
add the contents of the certificate in base64 format. -
In the configuration file
.aws/config
add a parameter:ca_bundle = <path>
Specify
<path>
— file pathroot.txt
.
Working with AWS CLI
For the syntax of the commands, see the instructions AWS Amazon documentation.
To work with object storage through the AWS CLI, use:
- s3api — commands corresponding to operations in the REST API;
- s3 — additional commands that simplify work with a large number of objects.
Display the list of containers
Print the list of containers:
aws s3 ls
Create a container
Create a container:
aws s3 mb s3://<container_name>
Specify <container_name>
— the name of the new container.
View list of objects
Check out the list of facilities:
aws s3 ls --recursive s3://<container_name>
Specify <container_name>
— container name.
Load object
Upload the files to the repository:
aws s3 cp <object_name> s3://<container_name>/
Specify:
<object_name>
— object name;<container_name>
— container name.
Delete object
Delete the object:
aws s3 rm s3://<container_name>/<object_name>
Specify:
<container_name>
— container name;<object_name>
— object name.