Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active May 12, 2024 23:36
Show Gist options
  • Save magnetikonline/cf40e813b7bb87e94df955d0c80cd310 to your computer and use it in GitHub Desktop.
Save magnetikonline/cf40e813b7bb87e94df955d0c80cd310 to your computer and use it in GitHub Desktop.
Install AWS CLI v2 from source.

Install AWS CLI v2 from source

Bash script to install the latest released version of the AWS CLI v2 from the distrubuted source.

Using this method to exectue the CLI under a MacBook M1 laptop as a native ARM binary - rather than falling back to Rosetta. Currently the offically packaged macOS .pkg doesn't support both Intel/M1 architectures.

Script designed to be re-run - will blow away an existing install and re-install the latest available version.

Note

This install script assumes you have installed a suitable version of Python 3 - has been tested against Python 3.10.11 under macOS Sonoma v14.4.1.

Usage

$ ./install.sh

$ which aws
/usr/local/bin/aws

$ aws --version
aws-cli/2.15.45 Python/3.10.11 Darwin/23.4.0 source-sandbox/arm64 prompt/off

Related

#!/bin/bash -e
# see: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-source-install.html
WORK_DIR=$(mktemp -d)
# install virtualenv
unset PIP_USER
PIP_USER="1" pip3 install --user virtualenv
# download source package and un-tar
curl --silent https://awscli.amazonaws.com/awscli.tar.gz | \
tar --directory "$WORK_DIR" --extract --gzip
pushd "$WORK_DIR"
cd "$(ls -1)"
# drop existing installed aws-cli, configure and install
sudo rm -fr /usr/local/lib/aws-cli
./configure --with-download-deps
make
sudo make install
popd
# cleanup
sudo rm -fr "$WORK_DIR"
aws --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment