awx is a minimal Bash CLI to streamline AWS profile switching and EKS kubeconfig management for multi-account AWS setups. It supports both SSO-based and static credential profiles transparently.
- Fuzzy, interactive AWS profile selection via
fzfbut also non-interactive mode:awx use --profile X --cluster Yfor scripts and automation - Toggle back to the previous AWS profile and EKS cluster with
awx -(likecd -) - Switch between existing kubeconfig contexts interactively with
awx ctx - Zsh tab completion for commands, subcommands, and AWS profile names
- Automatic SSO session re-authentication on every profile switch: if your session expires mid-day,
awxdetects it and re-authenticates transparently, with graceful fallback to static credentials when SSO fails - EKS kubeconfig management with caching that skips redundant updates when the target context already exists
- Lists all configured AWS profiles with
ACTIVE/EXPIREDsession status and remaining SSO session lifetime viaawx profiles - Display the active profile, region, and EKS cluster with
awx current - Reset environment and clear cached data with
awx clear - Force refresh of SSO session with
awx refresh
awx is a versatile script for managing AWS profiles and EKS kubeconfig contexts. Below are the primary commands and their purposes:
# Interactive mode (prompts with fuzzy finder)
awx # Select AWS profile and cluster
awx use # Same as awx
awx profile-name # Shortcut: set profile, then select cluster
# Non-interactive mode (for scripts and automation)
awx use --profile my-profile # Set profile without prompts
awx use --profile my-profile --cluster myc # Fully non-interactive
awx --profile my-profile # Top-level flag (equivalent to above)
# Other commands
awx whoami # Show current AWS identity
awx current # Show current profile, region, and cluster
awx clear # Unset AWS env vars and clear cache/state
awx refresh # Force refresh of SSO session
awx eks list # List available EKS clusters for active profile
awx eks update # Update kubeconfig for a specific cluster
awx ctx # Switch kubeconfig context via fzf
awx help or -h # Show detailed usage instructions
awx logout # Logout of the current AWS SSO session
awx profiles # List all configured AWS profiles with ACTIVE/EXPIRED status and remaining session time
awx update # Update awx to the latest version from GitHub$ awx
[INFO] Using profile: client-A (region: eu-central-1)
[INFO] Updating kubeconfig for cluster: cluster1-client-A
[INFO] Kubeconfig updated successfully
# On a repeated call when the context already exists:
$ awx
[INFO] Using profile: client-A (region: eu-central-1)
[INFO] Kubeconfig context already exists for cluster: cluster1-client-A, switching to context: client-AInstall awx with a single command:
curl -sSL https://raw.githubusercontent.com/cschindlbeck/awx/main/install.sh | bashThe script will:
- Download
awxto~/.local/bin/awx - Add a
sourceline to your shell config (~/.zshrcor~/.bashrc) - Auto-install Zsh completions if Oh My Zsh is detected
Then reload your shell and verify:
source ~/.zshrc # or ~/.bashrc
awx helpTo update awx at any time after installation:
awx updateEnvironment overrides (all optional):
| Variable | Default | Purpose |
|---|---|---|
INSTALL_DIR |
~/.local/bin |
Directory to install the awx script |
SHELL_RC |
auto-detected | Shell config file to add the source line to |
COMPLETIONS_DIR |
auto-detected | Directory for Zsh completion file |
BRANCH |
main |
GitHub branch to fetch from |
NO_MODIFY_SHELL_RC |
false |
Set to true to skip shell config modification |
Example: install to a custom directory without modifying the shell config:
INSTALL_DIR=~/bin NO_MODIFY_SHELL_RC=true \
curl -sSL https://raw.githubusercontent.com/cschindlbeck/awx/main/install.sh | bash- AWS CLI
- fzf
- jq
- kubectl (optional but recommended — enables fast context switching without a full
aws eks update-kubeconfigcall)
git clone https://github.com/cschindlbeck/awx.git
cd awx
# Step 1: Install via make (symlinks awx to ~/.local/bin)
make install
# Step 2: Add to your shell config (~/.zshrc or ~/.bashrc)
# This is REQUIRED so that AWS_PROFILE persists in your shell session
source "$HOME/.local/bin/awx"
# Then reload your shell
source ~/.zshrc # or ~/.bashrc
# (Optional) Install with oh-my-zsh
# ln -s $(pwd)/awx ~/.oh-my-zsh/custom/awx.zshWhy sourcing is required: awx needs to run in your shell's current process to modify environment variables like AWS_PROFILE. If executed as a subprocess (without sourcing), any environment changes are lost when the process exits. Sourcing the script defines the awx() function in your current shell, making your AWS profile switches persist.
Tab-completes commands, subcommands, and AWS profile names.
Plain zsh (add to ~/.zshrc):
fpath=(/path/to/awx/completions $fpath)
autoload -Uz compinit && compinitOh My Zsh:
mkdir -p ~/.oh-my-zsh/completions
cp completions/_awx ~/.oh-my-zsh/completions/
# Restart your shell or run: exec zshThis project uses automated tests and pre-commit hooks that run in CI to ensure code quality and correct behavior. All contributors should run both locally before pushing or submitting a pull request.
A Makefile provides a single, discoverable interface for the most common development workflows:
| Command | Description |
|---|---|
make help |
List all available targets |
make test |
Run all bats tests |
make lint |
Run pre-commit hooks on all files |
make check |
Run tests and lint |
make install |
Symlink awx to ~/.local/bin |
make dev |
Check development dependency status |
make clean |
Remove pre-commit cache and temp files |
-
The main suite is written in
bats-core. To use:On macOS:
brew install bats-core
On Linux/other platforms (manual install):
curl -fsSL https://github.com/bats-core/bats-core/archive/refs/heads/master.zip -o bats.zip unzip bats.zip && cd bats-core-master && ./install.sh ~/bats-local && cd .. rm -rf bats.zip bats-core-master export PATH=$HOME/bats-local/bin:$PATH
-
To run all tests via Make:
make test -
Or run bats directly:
bats tests
-
Run an individual test file:
bats tests/whoami.bats
Sample bats output:
1..4
ok 1 awx whoami with valid AWS_PROFILE
not ok 2 awx whoami with missing AWS_PROFILE
...
Automated quality checks, formatting, and linting are enforced by pre-commit.
- To run pre-commit hooks via Make:
make lint
- Or run pre-commit directly:
pre-commit run --all-files
- These hooks run automatically on commit/pull request via GitHub Actions. You must pass these checks for your contributions to be accepted.
Best practice: Always run make check before committing or opening a PR.
- If required tools (
aws,fzf, orjq) are missing,awxwill tell you exactly what to install. kubectlis an optional but recommended dependency. When present,awxskipsaws eks update-kubeconfigif the target context (named after the profile) already exists in your kubeconfig, and instead callskubectl config use-contextdirectly — significantly reducing latency on repeated calls. Withoutkubectl, a fullaws eks update-kubeconfigis always run.kubeconfigis updated per profile; back up your old file if you need persistent custom setups.- Credential detection is automatic:
awxchecks forsso_start_urlto detect SSO profiles andaws_access_key_idfor static credentials. No manual configuration required. - If a profile has both SSO and static credentials configured, SSO is attempted first. On SSO failure,
awxfalls back to static credentials automatically. - Defaults to region from
AWS_REGION, falling back toeu-central-1if unset. - EKS cluster results are cached per profile under
$XDG_CACHE_HOME/awx/(falls back to~/.cache/awx/). The default TTL is 8 hours (480 minutes) and can be overridden withAWX_CACHE_TTL=<minutes>.
Contributions, issues, and PRs are welcome!
To develop locally:
- Fork & clone.
- Install dependencies (see above).
- Run
make devto verify your local toolchain. - Make changes on a new branch.
- Run
make checkbefore opening a PR (runs tests and lint together).
