Created
May 28, 2024 12:59
-
-
Save saudkhanzada/4e336d49c84f931381ac65738c94a845 to your computer and use it in GitHub Desktop.
Getting AWS credentials using AWS SSO
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
# Add the following to your .zshrc or .bashrc | |
sso() { | |
local profile_name="$1" | |
# Check if the profile exists by attempting to get a known setting | |
if ! aws configure get sso_account_id --profile "$profile_name" &>/dev/null; then | |
echo "Profile '$profile_name' does not exist. Configuring AWS SSO profile..." | |
aws configure sso --profile "$profile_name" | |
fi | |
# Export credentials | |
eval "$(aws configure export-credentials --format env --profile "$profile_name")" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment