Installing and configuring AWS CLI

 

Overview

This article explains how to install and configure AWS CLI to interact with your DreamObjects account.

Background

AWS CLI is a command-line tool for managing data in Amazon S3 and other cloud storage service providers that use the S3 protocol, such as DreamObjects. It's best suited for users who are competent running SSH commands and is ideal for automated scripts triggered from a cron job.

Do I need to install AWS CLI?

AWS CLI is installed on all servers except Ubuntu Noble.

Installing a custom version of AWS CLI

This section explains how to install a custom version of Python 3 and create a virtual environment on a DreamHost server, or your local computer.

DreamHost servers

These steps assume you have already purchased a DreamObjects account and have configured a user and bucket.

  1. Log into your server via SSH.
  2. Install your preferred version of Python.
  3. Change into your user's home directory.
    [server]$ cd ~
  4. Run the following command to create a virtual environment.
    [server]$ virtualenv -p /home/username/opt/python-3.9.2/bin/python my-bucket
    A new directory named my-bucket is created.
  5. Activate this new virtual environment.
    [server]$ source ~/my-bucket/bin/activate

    When active, the command prompt changes to display the name of the virtual environment. For example:

    (my-bucket) 
  6. Install AWS CLI using pip.
    (my-bucket) pip install awscli
  7. Within your virtual environment, update the permissions of the new aws directory so you can run AWS CLI commands.
    (my-bucket) chmod +x ~/my-bucket/bin/aws

You can now proceed with configuring it to use your DreamObjects bucket.

macOS and Windows

Install Python

If you'd like to configure AWS CLI on your macOS or Windows computer, you must first install Python.

Configure a virtual environment

You can then proceed with creating a virtual environment. See this page for instructions. 

Install packages

Once created, you can then use the pip command to install packages within this virtual environment.

Configuring AWS CLI

This section configures your AWS CLI installation with your DreamObjects credentials.

 

Store your DreamObjects credentials

  1. Run aws configure to initiate the prompt.
    [user@localhost]$ aws configure
    AWS Access Key ID: **********
    AWS Secret Access Key: **********
    Default region name: us-east-005
    Default output format [None]:
    
  2. Copy your bucket's Access and Secret keys. AWS CLI stores them encrypted for you.
  3. Set the Default region to us-east-005.
  4. Leave the Default output format blank.
  5. Press Enter to save.

Add settings to the config file

Once the default profile has been set up, you will need to manually add these settings to your config file located at ~/.aws/config

region = us-east-005
Ignore_configure_endpoint_urls = true
Endpoint_url = https://s3.us-east-005.dream.io
#Configurations for checksums are required if using aws-cli version 2.23.0 or greater
request_checksum_calculation = WHEN_REQUIRED 

You can now run AWS CLI commands to interact with your DreamObjects bucket.

Automatically activate the virtual environment (Optional)

This step is optional, but helpful, as it allows the virtual environment to activate automatically when you log in. Otherwise, you'll need to manually activate it each time you log in.

To automatically activate your virtual environment when you log in, add the following line to your .bash_profile.

source ~/my-bucket/bin/activate

Make sure to change my-bucket to the name of the virtual environment you created.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?