-
-
Save dasgoll/450cc409e9a05ffcaab589d5f51a97b0 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 | |
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