A Zsh plugin for Oh My Zsh that simplifies switching between AWS profiles
- 🔄 Switch between AWS profiles with automatic SSO authentication
- 🎯 Interactive profile selection with fzf support
-
Clone this repository into your Oh My Zsh custom plugins directory:
git clone https://github.com/jmischler72/tfaws.git $ZSH_CUSTOM/plugins/tfaws -
Add
awsandtfawsto your plugins list in~/.zshrc:plugins=(... aws tfaws)
-
Reload your shell:
source ~/.zshrc
tfaws [COMMAND] [PROFILE]| Command | Description |
|---|---|
<profile> |
Switch to the specified AWS profile, if <profile> empty it clears profile |
ls, list |
List and interactively select an AWS profile |
sh, show |
Show current AWS profile and Terraform path |
# Switch to 'dev' profile
tfaws dev
# Interactive profile selection (uses fzf if available)
tfaws list
# Show current profile and path
tfaws show- Zsh shell
- Oh My Zsh
- AWS CLI v2 with configured profiles
fzf(optional, for enhanced interactive selection)
The plugin assumes you have AWS profiles configured and uses:
aws sts get-caller-identity- to check authentication statusaws sso login- for SSO authenticationaws_profiles- to list available profiles (assumed to be available)
Profile Switching: When you switch profiles, the plugin:
- Uses
asp(change_context) to set the AWS profile - Extracts the SSO session name from
~/.aws/config - Runs
aws sso loginto ensure authentication
- Profile not found: Ensure your AWS profile exists in
~/.aws/config - Authentication failed: The plugin will automatically run
aws sso loginwhen needed
Use tfaws show to see current configuration:
tfaws show
# Output:
# Current AWS Profile: dev
# Current Terraform Path: /home/user/terraform/devThis project is licensed under the terms specified in the LICENSE file.