This article uses the new DreamObjects cluster of 'objects-us-east-1.dream.io'. If you have an older DreamObjects account and have not migrated your data yet, your hostname may need to point to 'objects-us-west-1.dream.io instead. Please review the following migration article for further details.
- 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.
Installing AWS CLI
Depending on the operating system you are running, there are several options.
Windows: There are files in .msi format that can be installed directly.
Mac and Linux: The suggested installation is by running the Python “pip” command. To do this, run the following command on your local computer:
[[email protected]]$ pip install awscli
To install the client on a DreamHost Shared, VPS, or Dedicated server requires the use of Python's virtualenv. Then use “pip” to install the AWS CLI client locally with the same pip install command above. Please see the Python article for specifics on how to accomplish this.
Configuring AWS CLI
This client has features that apply to many services offered by Amazon, but this tutorial is only concerned with using the S3 functionality in combination with DreamObjects.
To use the S3 features, you must first configure a few things. Run the following command to input your access and secret keys for AWS CLI to store them encrypted for you. Accept the default region and output format by hitting enter.
[[email protected]]$ aws configure AWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: Default output format [None]:
Making a bucket
[[email protected]]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 mb s3://newbucketname make_bucket: s3://newbucketname/
Listing all buckets
[[email protected]]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 ls 2016-01-27 20:14:46 newbucketname
Uploading a file into a bucket
[[email protected]]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 cp testfile.txt s3://newbucketname/testfile.txt upload: ./testfile.txt to s3://newbucketname/testfile.txt
Listing the contents of a bucket
[[email protected]]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 ls s3://newbucketname 2016-01-27 19:30:21 8803 testfile.txt
Downloading a file from a bucket
[[email protected]]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 cp s3://newbucketname/testfile.txt testfile.txt download: s3://newbucketname/testfile.txt to ./testfile.txt
Deleting a file in a bucket
[[email protected]]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 rm s3://newbucketname/testfile.txt delete: s3://newbucketname/testfile.txt
Deleting an empty bucket
[[email protected]]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 rb s3://newbucketname/ remove_bucket: s3://newbucketname/
Sync a directory and its files to or from a bucket
This will only upload new and changed files, not delete any files. You can specify other params such as –delete to remove files from the destination that aren’t on the source. An additional useful flag is –acl which accepts values such as “private” or “public-read”.
[[email protected]]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 sync syncdir s3://newbucketname/ upload: syncdir/file3 to s3://newbucketname/file3 upload: syncdir/file1 to s3://newbucketname/file1 upload: syncdir/file2 to s3://newbucketname/file2