Last active
October 1, 2020 22:01
-
-
Save anlek/3e948851052020764fe7b853c711ffce to your computer and use it in GitHub Desktop.
BASH function to test what version of AWS CLI you're using.
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
[[ $(aws --version 2>&1) == aws-cli/1* ]] && echo "AWS CLI is V1" || echo "AWS CLI IS > V1" |
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
aws_cli_is_v1 () { | |
[[ $(aws --version 2>&1) == aws-cli/1* ]] && return 0 || return 1 | |
} | |
aws_cli_is_v2 () { | |
[[ $(aws --version 2>&1) == aws-cli/2* ]] && return 0 || return 1 | |
} | |
if [[ $(aws_cli_is_v1) ]]; then | |
echo "You're using AWS CLI v1" | |
elif [[ $(aws_cli_is_v2) ]]; then | |
echo "You're using AWS VLI v2" | |
else | |
echo "Are you from the future? Or maybe you don't have aws installed?" | |
fi | |
# Why is this helpful? I've had an issue where I'm trying to login into docker via ECR. | |
# AWS CLI V1 has a completely different docker login command from AWS CLI V2. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment