Skip to content

chris-code-lab/awsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

awsp

License: MIT Works with Oh My Zsh

Switch between AWS profiles interactively using fzf, or set one directly by name. Automatically triggers aws sso login if credentials are expired.

demo

Requirements

Installation

zsh (plain)

Clone the repo and add a source line to ~/.zshrc:

git clone https://github.com/chris-code-lab/awsp ~/.awsp
echo 'source ~/.awsp/awsp.plugin.zsh' >> ~/.zshrc && source ~/.zshrc

To update later: git -C ~/.awsp pull

Oh My Zsh

Oh My Zsh has its own plugin loader — clone directly into the custom plugins directory and it will find the plugin automatically:

git clone https://github.com/chris-code-lab/awsp ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/awsp

Then add awsp to the plugins array in ~/.zshrc and reload your shell:

plugins=(... awsp)
source ~/.zshrc

Plain zsh vs Oh My Zsh: with plain zsh you source the file yourself; with Oh My Zsh the framework handles loading — you just register the plugin name.

To update later: git -C ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/awsp pull

zinit

zinit can install directly from GitHub — add this to ~/.zshrc:

zinit light chris-code-lab/awsp

bash

Clone the repo and add a source line to ~/.bashrc:

git clone https://github.com/chris-code-lab/awsp ~/.awsp
echo 'source ~/.awsp/awsp.sh' >> ~/.bashrc && source ~/.bashrc

To update later: git -C ~/.awsp pull

Usage

awsp              # open fzf picker to select a profile
awsp my-profile   # set AWS_PROFILE directly
awsp none         # unset AWS_PROFILE

AWS profile configuration

awsp switches between profiles defined in ~/.aws/config. You need at least one profile configured before using it.

To add an SSO profile:

aws configure sso --profile my-profile

This will generate entries in ~/.aws/config similar to:

[sso-session my-org]
sso_start_url = https://my-org.awsapps.com/start
sso_region = eu-west-1
sso_registration_scopes = sso:account:access

[profile dev]
sso_session = my-org
sso_account_id = 123456789012
sso_role_name = MyRole
region = eu-west-1

[profile prod]
sso_session = my-org
sso_account_id = 210987654321
sso_role_name = MyRole
region = eu-west-1

For non-SSO profiles, use aws configure --profile my-profile. See the AWS CLI configuration docs for the full reference.


If you find this useful, give it a ⭐

About

A shell plugin to switch between AWS profiles interactively using fzf

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages