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.
Install fzf https://github.com/junegunn/fzf#installation
git clone https://github.dev/shidil/awsctx.git
cd awsctx
cp ./fish/awsctx.fish ~/.config/fish/functions/awsctx.fish
# for completion support
cp ./fish/completion.fish ~/.config/fish/completions/awsctx.fish
cat ./awsctx.sh >> ~/.bashrc
cat ./awsctx.sh >> ~/.zshrc
# This will show list of profiles and selection UI with fzf
awsctx
# To select profile directly
awsctx prod-env
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