Using the Object Storage Service – AWS CLI

Presentation

The AWS CLI (Command Line Interface) is free software (Apache 2.0 license) developed by Amazon Web Services to enable the use of AWS services through commands in a terminal (Linux shell, Windows command prompt, or macOS Terminal). This software allows managing storage as well as identities and permissions associated with them.
High-level commands (simpler) help avoid the complexity of the S3 API when manipulating buckets and objects.

Configuration

Prerequisite: Have the latest version of AWS CLI installed (on Linux, Windows, and macOS). Refer to the AWS documentation: What is the AWS Command Line Interface? – AWS Command Line Interface

Minimal configuration procedure:

  1. Open a Linux shell or Windows command window
  2. Run the command aws configure and enter:
    • Your AWS Access Key ID (access key)
    • Your AWS Secret Access Key (secret key)
    • EU for Default region name
    • Simply press Enter to accept the default output format

Note: Using the EU region does not mean your data is stored outside France; Cloud Avenue data is indeed stored in mainland France.

Usage examples

In the following examples, url represents the hostname of your service endpoint accessible via HTTPS (see your connection information).
The examples use “high-level” commands that hide the complexity of the S3 interface and correspond to simple use cases (managing buckets and objects).

Listing Buckets:

In the example, there are two buckets (comp1 and comp2).

Listing Bucket contents:

In the example, the bucket comp1 contains three files (fic2.txt, fichier1.txt, and fichierB2.txt) and a folder (or prefix) named backup. The contents of the folder are not listed here.

Recursively listing Bucket contents:

In the example, the Bucket comp1 contains 4 files, one of which is inside a folder named backup. The --recursive option allows listing all objects, including traversing folders (or prefixes).
The other two options may improve readability by displaying the size units of objects, the number of objects, and the total size.

Creating a Bucket

In the example, the empty Bucket comp3 is deleted.

Deleting a Bucket containing at least one object :

In the example, the comp1 Bucket is not empty; the –force option is used to automatically delete all objects and folders present.

Note : the –force option does not work if version management is enabled on the Bucket.

Manipulating objects

Copying an object to a Bucket:

In the example, the local file is copied (uploaded) to the comp2 Bucket.

Copying an object to a folder :

In the example, the miscellaneous folder is created if it does not already exist in the Bucket, then the local file is copied (uploaded) to the folder (or prefix).

Renaming an object :

In the example, the file fic2.txt is renamed fic2bis.txt.

Moving an object

In the example, the folder (or prefix) old is created, then the file fic2bis.txt is moved there.

Moving an object by renaming it :

In the example, the fileB2.txt object located in the miscellaneous folder is renamed and moved to the old folder (or prefix) as fileB2.bak

Deleting an object :

In the example, the fileB2.txt object is deleted; the miscellaneous folder (or prefix) is empty; it is automatically deleted.

Deleting a folder or a prefix

In the example, the deletion concerns the old folder; the –recursive option causes all objects present to be deleted (in this case, the Bucket is empty).