awsctx is a Go CLI similar to kubectx, built to switch AWS CLI profiles quickly.
It supports:
- Plain profiles from
~/.aws/credentials - SSO profiles from
~/.aws/config - Interactive selection through
fzf - Local
awsctxsettings customization - Writing/updating static and SSO profiles securely
go build -o bin/awsctx ./cmd/awsctxmkdir -p "$HOME/.local/bin"
cp bin/awsctx "$HOME/.local/bin/awsctx"Add to PATH (zsh):
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcDownload the latest binary for your platform, then move it into your PATH.
curl -L -o /tmp/awsctx https://github.com/kjvjobin/awsctx/releases/latest/download/awsctx_darwin_arm64
chmod +x /tmp/awsctx
sudo mv /tmp/awsctx /usr/local/bin/awsctxcurl -L -o /tmp/awsctx https://github.com/kjvjobin/awsctx/releases/latest/download/awsctx_darwin_amd64
chmod +x /tmp/awsctx
sudo mv /tmp/awsctx /usr/local/bin/awsctxcurl -L -o /tmp/awsctx https://github.com/kjvjobin/awsctx/releases/latest/download/awsctx_linux_amd64
chmod +x /tmp/awsctx
sudo mv /tmp/awsctx /usr/local/bin/awsctxVerify install:
awsctx --helpThen enable shell integration:
awsctx init zsh --write
source ~/.zshrcawsctx list
awsctx current
awsctx use <profile>
awsctx use <profile> --login
awsctx toggle
awsctx fzf
awsctx env
awsctx settings
awsctx init zsh
awsctx configure static ...
awsctx configure sso ...Install zsh integration once:
awsctx init zsh --write
source ~/.zshrcPreview the snippet before writing:
awsctx init zshIf you run from the repo binary directly:
bin/awsctx init zsh --write
source ~/.zshrcVerify:
awsctx use sandbox
echo "$AWS_PROFILE"
aws sts get-caller-identityLogin on demand for SSO profiles:
awsctx use sandbox --loginShow current settings:
awsctx settingsUpdate paths or fzf command:
awsctx settings \
--credentials-file ~/.aws/credentials \
--aws-config-file ~/.aws/config \
--state-file ~/.config/awsctx/state.json \
--fzf-command "fzf --height 40%"Enable auto SSO login during use, toggle, and fzf profile switches:
awsctx settings --auto-sso-login trueawsctx configure static \
--profile dev \
--access-key-id AKIA... \
--secret-access-key ... \
--region us-east-1awsctx configure sso \
--profile engineering \
--sso-start-url https://example.awsapps.com/start \
--sso-region us-east-1 \
--sso-account-id 123456789012 \
--sso-role-name Admin \
--region us-east-1awsctxuses strict file permissions (0700dirs,0600files) for its own state/config and rewritten AWS files.- Writes are atomic (
temp file + rename) to reduce corruption risk. awsctx usevalidates profile names from AWS files before activation.- Avoid passing secrets on CLI in shared environments because shell history may capture them; prefer env vars or prompt input.
- This tool rewrites INI files and does not preserve comments/order.