Skip to content
/ awsctx Public

Shell script to switch between aws cli profiles using fzf and trigger sso login if unauthenticated

License

Notifications You must be signed in to change notification settings

shidil/awsctx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

awsctx

Simple shell script to switch between different AWS_PROFILE variables from your aws-cli config. It uses the amazing fzf to provide fuzzy search UI for quick and interactive selection.

Installation

Install fzf https://github.com/junegunn/fzf#installation

git clone https://github.dev/shidil/awsctx.git
cd awsctx

Fish

cp ./fish/awsctx.fish ~/.config/fish/functions/awsctx.fish
# for completion support
cp ./fish/completion.fish ~/.config/fish/completions/awsctx.fish

Bash

cat ./awsctx.sh >> ~/.bashrc

Zsh

cat ./awsctx.sh >> ~/.zshrc

Usage

# This will show list of profiles and selection UI with fzf
awsctx

# To select profile directly
awsctx prod-env

Preview

Screen.Recording.2023-05-24.at.5.25.47.pm.mov

Given ~/.aws/config file like the example below

[profile prod-admin]
sso_session = orgname
sso_account_id = 1111111111
sso_role_name = AdministratorAccess
region = ap-southeast-2
output = json

[profile prod]
sso_session = orgname
sso_account_id = 1111111112
sso_role_name = ViewOnlyAccess
region = ap-southeast-2
output = json

[profile dev-admin]
sso_session = orgname
sso_account_id = 1111111113
sso_role_name = AdministratorAccess
region = ap-southeast-2
output = json

[profile another]
sso_session = orgname
sso_account_id = 22222222222
sso_role_name = ViewOnlyAccess
region = ap-south-1
output = json

[sso-session orgname]
sso_start_url = https://orgname.awsapps.com/start#
sso_region = ap-south-1
sso_registration_scopes = sso:account:access

About

Shell script to switch between aws cli profiles using fzf and trigger sso login if unauthenticated

Topics

Resources

License

Stars

Watchers

Forks

Languages