AWS CLI is a command-line tool for uploading, retrieving, and managing data in Amazon S3 and other Cloud Storage Service Providers that use the S3 protocol such as DreamObjects. It's best suited for power users who are competent with the command line and is ideal for scripts that are automated and triggered from cron.
The following instructions help you install and configure AWS CLI to work with DreamObjects.
Do I need to manually install AWS?
AWS is installed by default on most servers. However, it's possible you may still need to install this manually if your server is running Ubuntu 14.
AWS CLI is installed by default on all Shared servers. You can confirm if your site is on a Shared server on the Manage Domains page. To the right of your domain it will say 'Shared Hosting'. If so, you can proceed with configuring AWS below.
VPS and Dedicated servers
If you are running an older VPS or Dedicated server, it may be running Ubuntu 14. This link explains how you can confirm if your server is running Ubuntu 14.
If so, proceed with the steps below. If you see your server is already running Ubuntu 18 or Debian, skip to configuring AWS below.
Install Python 2.7.15 or newer
Due to a kernel update with Ubuntu, you must install Python 2.7.15 or newer in order to create a virtualenv. View the following articles to install a more recent version of Python:
Installing AWS CLI
Mac and Linux computers
Mac and Linux machines can install aw-cli by running the Python “pip” command. The following shows how to install aws-cli on a DreamHost server, however steps are the same for Mac and Linux machines.
To install the client on a DreamHost Shared, VPS, or Dedicated server requires the use of Python's virtualenv. Once the virtual environment is created and active, you can then use 'pip' to install the AWS CLI client locally.
- Log into your server via SSH.
- Install a custom version of Python as mentioned above.
- Make sure you're in your user's home directory.
[server]$ cd ~
- Create a virtual environment for a specific DreamObjects bucket. This virtual environment will store your DreamObjects bucket's credentials. This example names the virtual environment after your DreamObjects bucket name. The following command also assumes you've installed a custom version of Python as mentioned above. You can then specify the full path to your local install when creating the virtual environment. Make sure to change username to your Shell user.
[server]$ virtualenv -p /home/username/opt/python-2.7.15/bin/python my-bucket
- Activate this new virtual environment.
[server]$ source ~/my-bucket/bin/activate
- When you activate the virtual environment, the command prompt changes to show it's active. For example:
- Install aws-cli.
(my-bucket) pip install awscli
- Finally, update the permissions on the new aws directory so you can run aws commands.
(my-bucket) chmod +x ~/my-bucket/bin/aws
You can now proceed with configuring it to use your DreamObjects bucket.
Configuring AWS CLI
Run the following command to input your Access and Secret key for your bucket. aws-cli stores them encrypted for you.
Set the Default region to us-east-1.
Do not enter anything for the Default output format, then press Enter.
[user@localhost]$ aws configure AWS Access Key ID: ********** AWS Secret Access Key: ********** Default region name: us-east-1 Default output format [None]:
You can now run aws-cli commands to interact with your DreamObjects bucket.
View the following articles for examples of commands you can use to manage your DreamObjects data:
Configuring your user to automatically use the new virtual environment
When you follow the commands above, the virtual environment is activated during your session. However, if you log out and log back in, it will no longer be active.
To automatically activate your virtual environment when you log in, add the following to your .bash_profile.
Just change 'my-bucket' to the name of the virtual environment you created.