Skip to content

Instantly share code, notes, and snippets.

@anlek
Last active October 1, 2020 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anlek/3e948851052020764fe7b853c711ffce to your computer and use it in GitHub Desktop.
Save anlek/3e948851052020764fe7b853c711ffce to your computer and use it in GitHub Desktop.
BASH function to test what version of AWS CLI you're using.
[[ $(aws --version 2>&1) == aws-cli/1* ]] && echo "AWS CLI is V1" || echo "AWS CLI IS > V1"
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