Skip to content

Instantly share code, notes, and snippets.

@SevanBadal
Last active May 5, 2025 05:40
Show Gist options
  • Select an option

  • Save SevanBadal/674c9bc300212ed230b3115e6d748ef8 to your computer and use it in GitHub Desktop.

Select an option

Save SevanBadal/674c9bc300212ed230b3115e6d748ef8 to your computer and use it in GitHub Desktop.
AWS Profile Switcher: An interactive Bash tool that simplifies switching between AWS CLI profiles. Provides a numbered menu of available profiles from your AWS config, sets the selected profile as the current AWS_PROFILE environment variable, and displays identity information—eliminating the need to repeatedly type '--profile' flags.
# Configure AWS CLI
select_aws_profile() {
echo "Available AWS Profiles:"
PS3="Select AWS profile (enter number): "
# Get profiles directly using grep and sed
profiles=($(grep '^\[profile' ~/.aws/config | sed 's/\[profile \(.*\)\]/\1/') "Skip")
select profile in "${profiles[@]}"; do
[[ "$profile" == "Skip" ]] && break
if [[ -n "$profile" ]]; then
export AWS_PROFILE=$profile
echo "Switched to AWS Profile: $profile"
aws sts get-caller-identity
break
fi
done
}
alias awsp='select_aws_profile'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment