Fork me on GitHub

Project Notes

aws-cli

Installing the running the AWS CLI

Notes

Just the basics of instlaling and running the AWS CLI, updated for version 2.

AWS CLI version 2

Installing, updating, and uninstalling the AWS CLI version 2

Local Install - MacOS

Download and run the installer: https://awscli.amazonaws.com/AWSCLIV2.pkg After installation:

$ which aws
/usr/local/bin/aws
$ aws --version
aws-cli/2.2.7 Python/3.8.8 Darwin/17.7.0 exe/x86_64 prompt/off

Update: installed on macOS 14.2.1 (Apple Silicon):

$ aws --version
aws-cli/2.15.6 Python/3.11.6 Darwin/23.2.0 exe/x86_64 prompt/off

Running With Docker

The CLI is now also available as a docker image:

$ docker run --rm -it amazon/aws-cli --version
aws-cli/2.2.7 Python/3.8.8 Linux/4.19.76-linuxkit docker/x86_64.amzn.2 prompt/off

To share aws credentials in the local ~/.aws folder, map the volume:

$ docker run --rm -it -v ~/.aws:/root/.aws amazon/aws-cli --profile myprofile s3 ls s3://example.bucket
... returns authorised results..

To upload/download data from localfile system (current directory: $(pwd)), also map the volume to /aws:

$ docker run --rm -it -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli s3 cp s3://aws-cli-docker-demo/hello .
download: s3://aws-cli-docker-demo/hello to ./hello
$ cat hello
Hello from Docker!

AWS CLI version 1

Installing, updating, and uninstalling the AWS CLI version 1

Installing AWS CLI version 1

A long time ago (back in python 2 days!), I installed, the AWS CLI tools with pip:

$ pip install awscli
$ aws --version
aws-cli/1.16.63 Python/2.7.15 Darwin/17.7.0 botocore/1.12.53

Uninstalling AWS CLI version 1

This is the problem with locally installed packages - they can become unhinged. My old aws cli is installed and works, but pip can’t uninstall it…

$ which aws
/usr/local/bin/aws

$ pip uninstall awscli
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: Skipping awscli as it is not installed.

That’s because I’ve re-installed python so many times since, and also switched to using pyenv, that the actual awscli site-package is no longer on the paths that my default python2/pip2 executable will find:

$ find / -name awscli -type d
...
/usr/local/lib/python2.7/site-packages/awscli
...

That’s because two separate python 2 installations. pip is coming from the pyenv version

$ pip --version
pip 19.2.3 from /Users/paulgallagher/.pyenv/versions/2.7.18/lib/python2.7/site-packages/pip (python 2.7)

while aws is linked to an older python 2 - I think this is the defualt MacOS python:

$ head -1 /usr/local/bin/aws
#!/usr/local/opt/python@2/bin/python2.7

So for now I just took the cheats way out and moved the aws command out of the way so I can install v2:

mv /usr/local/bin/aws /usr/local/bin/aws.v1

Credits and References

About LCK#174 toolsAWS
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.