Skip to content

Instantly share code, notes, and snippets.

@wfairclough
Last active February 28, 2024 02:04
Show Gist options
  • Save wfairclough/df8229ea0da2a46a7b7f1e424e2f2d56 to your computer and use it in GitHub Desktop.
Save wfairclough/df8229ea0da2a46a7b7f1e424e2f2d56 to your computer and use it in GitHub Desktop.
AWS cli SSO quick select shell script
#!/bin/bash
#
# Quick search and select the AWS profile to use for SSO login
AWS_PROFILE=$(cat ~/.aws/config | rg 'profile' | awk '{print $2}' | sed 's/]//g' | sort | fzf)
if [ -z "$AWS_PROFILE" ]; then
echo "No profile selected"
exit 1
fi
export AWS_PROFILE
aws sso login
echo "You are now logged in to AWS with the $AWS_PROFILE profile"
echo ""
echo "export AWS_PROFILE=\"$AWS_PROFILE\""
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment