AWS CLI
In this article:
AWS CLI#
Configure AWS CLI#
Before installation, get API access settings in the cloud management console. Click the user login in the top right corner, select Profile Get API access settings.
Install AWS CLI:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install
Configure AWS CLI using API access settings you’ve got:
user@cloud:~$ aws configure AWS Access Key ID [None]: <Project ID in K2 Cloud>:<Your login in K2 Cloud> AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXXXXXXX Default region name [None]: US Default output format [None]: json
When using AWS CLI version 1.37.0 and higher, or version 2.23.0 and higher to work with the object storage, set up the checksum verification, when necessary for API operations. To do so, add the following parameters to the
~/.aws/configfile:request_checksum_calculation = WHEN_REQUIRED response_checksum_validation = WHEN_REQUIRED
Command examples for operating with object storage#
Show the list of buckets in your project#
aws s3 ls --endpoint-url=https://s3.ru-msk.k2.cloud
Output:
2017-10-18 00:28:50 mybucket
Show the bucket content#
aws s3 ls --endpoint-url=https://s3.ru-msk.k2.cloud s3://mybucket
Output:
2018-04-04 13:56:00 17666 file1.txt
2018-04-04 13:50:48 317565 file2.txt
2018-04-04 13:51:38 117018 file3.jpeg
Delete an object#
aws s3 rm --endpoint-url=https://s3.ru-msk.k2.cloud s3://mybucket/file1.txt
Output:
delete: s3://mybucket/file1.txt
Upload file to the bucket#
aws s3 cp test.txt s3://mybucket/test.txt --endpoint-url=https://s3.ru-msk.k2.cloud
Output:
upload: ./test.txt to s3://mybucket/test.txt