Last active
May 5, 2025 05:40
-
-
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.
This file contains hidden or 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
| # 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