latest/1.18.129
(1.18.129/Dockerfile) - Sept 01, 20201.18.4
(1.18.4/Dockerfile) - Feb 21, 20201.17.5
(1.17.5/Dockerfile) - Jan 18, 20201.16.313
(1.16.313/Dockerfile) - Jan 09, 20201.16.305
(1.16.305/Dockerfile) - Dec 18, 2019
docker run -rm \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
rommelporras/aws-cli \
s3 ls
or
docker build -t rommelporras/aws-cli:latest .
Docker container with the AWS CLI installed.
Using Alpine linux. The Docker image is 49MB
An automated build of this image is on Docker Hub: https://hub.docker.com/r/rommelporras/aws-cli/
Configure:
export AWS_ACCESS_KEY_ID="<awsid>"
export AWS_SECRET_ACCESS_KEY="<awskey>"
export AWS_DEFAULT_REGION="eu-west-1"
alias aws='docker run --rm -t $(tty &>/dev/null && echo "-i") -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}" -v "$(pwd):/project" rommelporras/aws-cli'
or
alias aws='docker run --rm -t $(tty &>/dev/null && echo "-i") -e "AWS_ACCESS_KEY_ID=AKIA2XXXXXXXXX" -e "AWS_SECRET_ACCESS_KEY=q/z4m+jgXXXXXXXXXX" -e "AWS_DEFAULT_REGION=eu-west-1" -v "$(pwd):/project" rommelporras/aws-cli'
docker run -rm \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
--env AWS_DEFAULT_REGION=us-east-1 \
rommelporras/aws-cli \
ec2 describe-instances --instance-ids i-90949d7a
or
aws ec2 describe-instances --instance-ids i-90949d7a #apply alias first
output:
{
"Reservations": [
{
"OwnerId": "960288280607",
"ReservationId": "r-1bb15137",
"Groups": [],
"RequesterId": "226008221399",
"Instances": [
{
"Monitoring": {
"State": "enabled"
},
"PublicDnsName": null,
...
...
}
First: Update the environment credentials in docker-compose.yml
docker-compose run aws s3 ls
output:
2019-10-17 13:07:17 sftp-bucket-ips
2019-04-30 09:48:13 rommelporras-dev-bucket
docker run -rm \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
rommelporras/aws-cli \
s3 ls
output:
2019-12-19 01:41:30 Assets
2014-06-06 01:02:29 Layouts
Upload content of your current directory (say it contains two files test.txt and test2.txt) to s3 bucket
docker run -rm \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
-v $PWD:/data \
rommelporras/aws-cli \
s3 sync . s3://mybucketname
output:
(dryrun) upload: test.txt to s3://mybucketname/test.txt
(dryrun) upload: test2.txt to s3://mybucketname/test2.txt
doc: http://docs.aws.amazon.com/cli/latest/reference/s3/index.html
We will map the private keys that resides on your local system to inside the container
docker run -rm \
-v <<LOCATION_TO_YOUR_PRIVATE_KEYy>>:/tmp/key.pem \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
--env AWS_DEFAULT_REGION=us-east-1 \
rommelporras/aws-cli \
ec2 get-password-data --instance-id <<YOUR_INSTANCE_ID>> --priv-launch-key /tmp/key.pem
Output:
{
"InstanceId": "i-90949d7a",
"Timestamp": "2014-12-11T01:18:27.000Z",
"PasswordData": "8pa%o?foo"
}
doc: http://docs.aws.amazon.com/cli/latest/reference/ec2/get-password-data.html
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-command-line