Last active
January 15, 2023 21:52
-
-
Save jamesls/3623e9589db175509ec2c61536b6c6b9 to your computer and use it in GitHub Desktop.
AWS CLI v2 upgrade aliases.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 | |
# This version doesn't work on >= Catalina 10.15, use the alternate | |
# implementation below. | |
# | |
# 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 | |
# This version works on Catalina (10.15) and higher. | |
# | |
check-upgrade = !f() { | |
rm -f /tmp/AWSCLIV2.pkg | |
curl -s "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "/tmp/AWSCLIV2.pkg" | |
(cd /tmp/ && xar -x --exclude Distribution --exclude Resources -f /tmp/AWSCLIV2.pkg) | |
latest_cli_version=$(grep -a '<pkg-info' < /tmp/aws-cli.pkg/PackageInfo | \ | |
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
Is there a similar versioned path for the Linux zip-based installer?