Skip to main content
AWS CLI

AWS CLI

AWS CLI (AWS Command Line Interface) is a command line interface for working with AWS services.

Customize AWS CLI

  1. Configure access.
  2. Install the client.
  3. Create an AWS CLI configuration.
  4. Install the certificate.

1. Set up access

Access can be configured by a user with the Account Owner or User Administrator role.

  1. Create a service user с role with access to the object store.If you are using a user with the Object Storage User role, the container must have a configured access policy.
  2. Issue an S3 key to the user.

2. Install the client

Use the Install or update to the latest version of the AWS CLI documentation from Amazon.

3. Create an AWS CLI configuration

  1. Open the terminal.

  2. Open the configuration mode:

    aws configure
  3. Enter the AWS Access Key ID, which is the value of the Access key field from the S3 key.

  4. Enter AWS Secret Access Key — the value of the Secret key field from the S3 key.

  5. Enter Default region name — the pool where the object store is located (for example, ru-1).

  6. Enter Default output format or leave blank.

  7. 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 = <pool>

4. Install the certificate

  1. Create a folder ~/.servercores3/:

    mkdir -p ~/.servercores3/
  2. Download the certificate and place it in the ~/.servercores3/ folder:

    wget https://secure.globalsign.net/cacert/root-r6.crt -O ~/.servercores3/root.crt
    openssl x509 -inform der -in ~/.servercores3/root.crt -out ~/.servercores3/root.crt
    chmod 600 ~/.servercores3/root.crt
  3. In the .aws/config configuration file, add a parameter:

    ca_bundle = ~/.servercores3/root.crt

Working with AWS CLI

For the command syntax, see the AWS instructions in Amazon's AWS 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> is 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> is the name of the container.

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.