Skip to content

Instantly share code, notes, and snippets.

@dasgoll
Forked from jamesls/alias
Created August 8, 2020 15:34
Show Gist options
  • Save dasgoll/450cc409e9a05ffcaab589d5f51a97b0 to your computer and use it in GitHub Desktop.
Save dasgoll/450cc409e9a05ffcaab589d5f51a97b0 to your computer and use it in GitHub Desktop.
AWS CLI v2 upgrade aliases.
[toplevel]
# Put this in ~/.aws/cli/alias
# and you'll have an "aws upgrade"
# and an "aws check-upgrade" command.
#
# Only works on macOS and installs using
# the .pkg installer.
#
upgrade = !f() {
curl -s "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "/tmp/AWSCLIV2.pkg"
sudo installer -pkg /tmp/AWSCLIV2.pkg -target /
rm -f /tmp/AWSCLIV2.pkg
}; f
check-upgrade = !f() {
rm -f /tmp/AWSCLIV2.pkg
latest_cli_version=$(curl -s "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o - | \
tar xOv - 2>/dev/null | \
grep -a '<pkg-info' | \
sed "s#.* version=\"\([0-9\.]*\)\".*#\1#")
release_date=$(curl -sI "https://awscli.amazonaws.com/AWSCLIV2.pkg" | \
grep 'Last-Modified' | cut -d':' -f 2- | tr '\r\n' ' ')
echo "Current version: $(aws --version | cut -d' ' -f 1)"
echo " New version: aws-cli/${latest_cli_version} (${release_date})"
}; f
install-version = !f() {
curl -s "https://awscli.amazonaws.com/AWSCLIV2-$1.pkg" -o "/tmp/AWSCLIV2.pkg"
sudo installer -pkg /tmp/AWSCLIV2.pkg -target /
rm -f /tmp/AWSCLIV2.pkg
}; f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment