Skip to content

Instantly share code, notes, and snippets.

@robbwagoner
Last active June 8, 2021 12:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robbwagoner/f2ce4d32471ea9859e86ec7a1308092e to your computer and use it in GitHub Desktop.
Save robbwagoner/f2ce4d32471ea9859e86ec7a1308092e to your computer and use it in GitHub Desktop.
AWS CLI with PEX

What is PEX?

build with Docker image... e.g. Ubuntu 14.04

$ docker run --rm -it -v $PWD:/src -w /src ubuntu:14.04

Install PEX

ubuntu14# apt update && apt -y install python3 python3-pip && pip3 install pex

Build aws.pex

ubuntu14# pex -r <(echo awscli) -c 'aws' -o aws.pex

Exit Container

ubuntu14# exit

aws.pex works just like the regular CLI

$ docker run --rm -it -v $PWD:/src -w /src ubuntu:14.04 ./aws.pex --version
aws-cli/1.15.76 Python/3.4.3 Linux/4.9.93-linuxkit-aufs botocore/1.10.75

Copy aws.pex to any Ubuntu 14.04 which doesn't have Python or PIP installed

scp aws.pex ubuntu.example.com

Install and symlink

sudo mv aws.pex /usr/local/bin
sudo ln -s aws.pex /usr/local/bin/aws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment