├── Dockerfile └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM alpine:latest 3 | 4 | RUN apk add --update \ 5 | python \ 6 | groff \ 7 | py2-pip && \ 8 | adduser -D aws 9 | 10 | ENV PAGER='cat' 11 | 12 | WORKDIR /home/aws 13 | 14 | RUN mkdir aws && \ 15 | pip install --upgrade pip && \ 16 | pip install awscli 17 | 18 | USER aws 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS CLI on CoreOS 2 | 3 | No, you can't install `aws-cli` on CoreOS. 4 | 5 | Yes, you can run this container and call out to it. 6 | 7 | ## Problem 8 | 9 | I wanted to pull container images from my Elastic Container Registry (ECR) into my CoreOS on EC2, but in an automated way. 10 | 11 | * Sure I could do it manually just fine. 12 | * I wanted to do it automatically. 13 | * AWS documentation offered no obvious solution beyond "use ECS" which has its own share of problems. 14 | 15 | ## Solution 16 | 17 | Run a container within CoreOS that has the aws cli tools installed, and simply mount a volume from CoreOS that contains the necessary configuration. Run commands from within that. 18 | 19 | ## Instructions 20 | 21 | ### Run 22 | 23 | ```bash 24 | docker build -t jdrago999/aws-cli . 25 | ``` 26 | 27 | ### Configuration files 28 | 29 | Make sure `~/.aws/config` and `~/.aws/credentials` exist in your CoreOS instance. 30 | 31 | #### `~/.aws/config` 32 | 33 | ``` 34 | [default] 35 | region = us-east-1 36 | ``` 37 | 38 | #### `~/.aws/credentials` 39 | 40 | ``` 41 | [default] 42 | aws_access_key_id = AKIXXXXXXXXXXXXXXXXX 43 | aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 44 | ``` 45 | 46 | ### Run your commands within the container 47 | 48 | ```bash 49 | docker run -it -v $HOME/.aws:/home/aws/.aws jdrago999/aws-cli 50 | ``` 51 | 52 | #### Examples 53 | 54 | **List Buckets** 55 | 56 | ```bash 57 | docker run -it -v $HOME/.aws:/home/aws/.aws jdrago999/aws-cli aws s3 ls 58 | ``` 59 | 60 | **Get ECR Login** 61 | 62 | ```bash 63 | docker run -it -v $HOME/.aws:/home/aws/.aws jdrago999/aws-cli aws ecr get-login 64 | ``` 65 | 66 | **Use a named profile** 67 | 68 | ```bash 69 | run -it -v $HOME/.aws:/home/aws/.aws jdrago999/aws-cli aws ecr get-login --profile groove 70 | ``` 71 | 72 | ## See Also 73 | 74 | * https://www.linkedin.com/pulse/use-aws-cli-from-coreos-via-docker-easy-way-john-drago 75 | 76 | --------------------------------------------------------------------------------