AWS Command Line Interface
The AWS Command Line Interface (CLI) is a command line tool for accessing AWS and compatible services. This makes it ideal for accessing StorReduce, because StorReduce has a faithful implementation of the Amazon S3 API.
To install the AWS CLI please follow the instructions on the AWS website. If you are on the StorReduce Virtual Appliance, or running Amazon Linux in EC-2 then it may already be installed.
Configuring a StorReduce Profile
The best way to use the AWS CLI with StorReduce is add a profile in the CLI configuration files. A profile is a set of settings that apply to a particular cloud endpoint. Doing this avoids messing up the AWS profile that you might use with AWS in the future. For this example, let’s call the profile “storreduce”.
The profile is stored in the
~/.aws directory on Unix, Linux and
OS/X and in
configfile in the
.awsAdd a line profile line at the end of the config file like this at the end of the file:
Then save the file. You don’t need to set any variables at this time, you just have to name the profile.
credentialsfile in the same directory and add the following lines at the end of the file:
[storreduce] aws_access_key_id = YOUR_STORREDUCE_ACCESS_KEY_ID aws_secret_access_key = YOUR_STORREDUCE_SECRET_ACCESS_KEY
You can obtain the
YOUR_STORREDUCE_SECRET_ACCESS_KEYand from the StorReduce dashboard. See the section “Create a key for a user” in the getting started guide.
You can now test the CLI. When you run the aws command, you’ll need to specify the
endpoint-urlon the command line. E.g.,
aws --profile=storreduce --endpoint-url=http://YOUR_STORREDUCE_SERVER s3 ls
Where YOUR_STORREDUCE_SERVER is the domain name of your storreduce server. This must match the hostname configured in the StorReduce Servers Settings tab and it must be resolvable in DNS or a hosts file. This command should list the buckets in your StorReduce server.
If there is an error contacting the server, check that the access keys that you added in step 3 are correct (you can always issue another pair). If that doesn’t work check that that the hostname matches and that it resolvable.
Once you have listed the all the buckets you can try:
Listing a bucket:
aws --profile=storreduce --endpoint-url=http://YOUR_STORREDUCE_SERVER s3 ls s3://BUCKET_NAME
Note: This should all go on one line.
Copying a file into a bucket:
aws --profile=storreduce --endpoint-url=http://YOUR_STORREDUCE_SERVER s3 cp FILE_NAME s3://BUCKET_NAME
Copying a file out of a bucket:
aws --profile=storreduce --endpoint-url=http://YOUR_STORREDUCE_SERVER s3 cp s3://BUCKET_NAME/FILE_NAME FILE_NAME
Syncing a directory with a bucket:
aws --profile=storreduce --endpoint-url=http://YOUR_STORREDUCE_SERVER s3 DIRECTORY_NAME s3://BUCKET_NAME
To save typing you can make a shell script like this:
#!/bin/sh exec aws --profile=storreduce --endpoint-url=http://YOUR_STORREDUCE_SERVER s3 "$@"
and save it as
srcli and run it like this:
Configuration and Credential Files contains more information about the the
.awsconfiguration directory and how the configuration files interact with environment variables.
See Using the AWS Command Line Interface for more general information about how to use the CLI.