Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 1.34 KB

README.md

File metadata and controls

38 lines (29 loc) · 1.34 KB

aws-cli through Docker

Universal Command Line Interface for Amazon Web Services through Docker.

Usage

docker run --rm -i \
-e AWS_ACCESS_KEY_ID=[your-aws-access-key-id] \
-e AWS_SECRET_ACCESS_KEY=[your-ws-secret-access-key] \
creativearea/aws [options] <command> <subcommand> [parameters]

You can also use a config file to tell AWS cli about your credentials:

docker run --rm -i \
-v $(pwd)/config:/root/.aws
creativearea/aws [options] <command> <subcommand> [parameters]

Please refer to Getting Started and the Configurable Variables sections of the AWS Cli documentation.

Use case

Let's say for example you want to periodically backup your MySQL database (running in another Docker container) to an S3 bucket. You could setup a daily cronjob on your host that run the following command:

docker run --rm -i \
--link mysql:mysql \
mysql \
sh -c 'exec mysqldump -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" my-app-database' \
| \
docker run --rm -i \
-e AWS_ACCESS_KEY_ID=xxxxxxxxxxxx \
-e AWS_SECRET_ACCESS_KEY=xxxxxxxxxx \
creativearea/aws s3 cp - s3://[aws-bucket-name]/mysql_backup_$(date "+%y%m%d").sql