A collection of portable shell functions that streamline working with AWS CLI, especially when using AWS SSO / IAM Identity Center.
The toolkit works in both bash and zsh, contains no shell-specific
syntax, and requires only the AWS CLI and jq.
- Automatically detect SSO base profiles
- Extract SSO tokens from AWS cache
- Generate AWS profiles for all accounts and roles (
awssyncprofiles)
awsjumplets you pick account → role via a 2-step menu- Automatically sets
AWS_PROFILE - Sorted alphabetically
- No AWS API calls → instant
awsfixautomatically detects expired credentials- Offers to run
aws sso loginwhen needed
awswhereshows who you are (profile, region, ARN, account)awsprofileslists all profiles with SSO metadataawsclearresets all AWS-related environment variables
Clone your dotfiles repo (or create the folder):
mkdir -p ~/dev/dotfiles/aws-tools
cd ~/dev/dotfiles/aws-toolsPlace aws-tools.sh in this directory.
Add this to your ~/.zshrc or ~/.bashrc:
AWS_TOOLS="$HOME/dev/dotfiles/aws-tools/aws-tools.sh"
[ -f "$AWS_TOOLS" ] && source "$AWS_TOOLS"Reload your shell:
source ~/.zshrc # or: source ~/.bashrc- AWS CLI v2+
- jq (required for JSON parsing)
macOS:
brew install awscli jqDebian/Ubuntu:
sudo apt install awscli jqaws sso login --profile <base-profile>awssyncprofiles <base-profile> > ~/.aws/sso-generated-profiles
cat ~/.aws/sso-generated-profiles >> ~/.aws/configProfiles are created in the form:
marketing-shared-AWSAdministratorAccess
product-core-AWSReadOnlyAccess
awsjumpThis sets:
export AWS_PROFILE="<account>-<role>"awswhereawsfixawsprofilesawsclear| Function | Description |
|---|---|
awsbase |
Detect or select a base SSO profile |
aws_sso_token |
Extract SSO access token from AWS cache |
awssyncprofiles |
Generate AWS config profiles for all SSO accounts/roles |
awsjump |
Two-step selector (account → role), sets AWS_PROFILE |
awsfix |
Refresh expired SSO credentials |
awswhere |
Show current account/ARN/profile |
awsprofiles |
Display all profiles with SSO metadata |
awsclear |
Clear AWS_* environment vars |
~/.aws/config
~/.aws/credentials
~/.aws/sso-generated-profiles # append this to config
Ensure your shell sources the toolkit:
source ~/dev/dotfiles/aws-tools/aws-tools.shRun:
awsfixRegenerate:
awssyncprofiles <base-profile>Free to use and modify for personal or professional setups.