AWS CLI
AWS CLI (AWS Command Line Interface) is a command line interface for working with AWS services.
Through the AWS CLI, you can work with the S3 API.
Customize AWS CLI
1. Configure access
Access can be configured by a user with role Account Owner or User Administrator.
- Create a service user with a role with access to object storage, see Role Model Access for details.
- Issue the user an S3 key.
2. Install the client
Use the Install or update to the latest version of the AWS CLI instructions in the Amazon documentation.
3. Create an AWS CLI configuration
-
Open the terminal.
-
Open the configuration mode:
aws configure
-
Enter
AWS Access Key ID
— the value of the Access key field from S3-key. -
Enter
AWS Secret Access Key
— the value of the Secret key field from the S3 key. -
Enter
Default region name
— pool (ru-1). -
The settings will be saved in the configuration files:
-
credentials in
.aws/credentials
:[default]
aws_access_key_id = <access_key>
aws_secret_access_key = <secret_key> -
default pool in
.aws/config
:[default]
region = ru-1
-
-
If you want to use Virtual-Hosted addressing, add a parameter to the
.aws/config
configuration file:[default]
s3 =
addressing_style = virtual
Working with AWS CLI
For command syntax, see the AWS instructions in the Amazon documentation.
To work with object storage through the AWS CLI, use:
- s3api — commands corresponding to operations in the REST API;
- s3 — additional commands simplifying work with a large number of objects.
When running the aws
command, the --endpoint-url=https://s3.ru-1.storage.selcloud.ru
parameter is mandatory, where ru-1
is pool.
Create a container
Create a container:
aws --endpoint-url=https://s3.ru-1.storage.selcloud.ru s3 mb s3://<container_name>
Specify:
ru-1
— pool;<container_name>
is the name of the new container.
View a list of facilities
Check out the list of facilities:
aws --endpoint-url=https://s3.ru-1.storage.selcloud.ru s3 ls --recursive s3://<container_name>
Specify:
ru-1
— pool;<container_name>
is the name of the container.
Download the object
Upload the files to the repository:
aws --endpoint-url=https://s3.ru-1.storage.selcloud.ru s3 cp <object_name> s3://<container_name>/
Specify:
ru-1
— pool;<object_name>
is the name of the object;<container_name>
is the name of the container.
Delete object
Delete the object:
aws --endpoint-url=https://s3.ru-1.storage.selcloud.ru s3 rm s3://<container_name>/<object_name>
Specify:
ru-1
— pool;<container_name>
is the name of the container;<object_name>
is the name of the object.