I found myself constantly juggling between multiple AWS accounts and EKS clusters, going through the same tedious process:
- Remembering the correct AWS profile names
- Running
aspto switch profiles - Logging in via SSO
- Updating kubeconfig manually
- Trying to remember which clusters belonged to which account
This tool streamlines this entire workflow into a single command, making it easy to switch between different AWS accounts and their corresponding EKS clusters.
Tool for moving to a different EKS cluster using AWS profiles. It automatically:
- Switches AWS profiles
- Handles SSO login
- Updates kubeconfig
- Lists available clusters
- AWS CLI installed
- AWS SSO configured
- AWS profiles set up in
~/.aws/config - kubectl installed
Ensure your AWS profiles are properly configured in ~/.aws/config:
[profile dev]
sso_start_url = https://your-sso-url.awsapps.com/start
sso_region = eu-central-1
sso_account_id = 123456789012
sso_role_name = YourRole
region = eu-central-1
[profile prod]
sso_start_url = https://your-sso-url.awsapps.com/start
sso_region = eu-central-1
sso_account_id = 987654321098
sso_role_name = YourRole
region = eu-central-1asp-eks [command]completion: Generate the autocompletion script for the specified shellgenerate-profiles: Generate AWS profiles for all SSO accounts and roleshelp: Help about any commandlist: List available AWS profilessearch: Search for AWS profiles by name (case-insensitive substring match)use: Use a specific AWS profile and set kubeconfig for an EKS cluster
asp-eks search <query>Case-insensitive substring search across all configured AWS profile names.
asp-eks search np20 # matches cluster-np20-dev, np20-dev-cluster, etc.
asp-eks search prod # matches any profile containing "prod"The generate-profiles command automatically creates AWS profiles for all accounts and roles accessible through your SSO configuration. This is particularly useful when you have access to multiple AWS accounts through SSO and want to avoid manually creating profiles for each account/role combination.
Important:
- If you do not have a
~/.aws/configfile, you must provide the--sso-start-urlflag to specify your AWS SSO start URL. The tool will create a minimal config file for you. - If you already have a config file with SSO configuration, the flag is optional and will override the SSO start URL for that run.
Features:
- Automatically discovers all accounts and roles available through SSO
- Generates profiles with consistent naming:
<account-name>-<role-name> - Supports dry-run to preview profiles before creating them
- Configurable default region for all generated profiles
Options:
--dry-run: Show what profiles would be generated without writing to config file--region, -r: Default AWS region for generated profiles (default "eu-central-1")--sso-start-url: Override or set the SSO start URL for generated profiles (required if no config file exists)
Prerequisites:
- You must be logged in to AWS SSO (run
aws sso login --profile DEFAULT-SSOafter first run) - You must have at least one SSO profile configured in
~/.aws/config, or provide--sso-start-urlto create one
Examples:
# Preview profiles that would be generated (with a new SSO start URL)
asp-eks generate-profiles --dry-run --sso-start-url https://your-sso-url.awsapps.com/start
# Generate profiles (will require --sso-start-url if no config exists)
asp-eks generate-profiles --sso-start-url https://your-sso-url.awsapps.com/start
# Generate profiles with custom default region
asp-eks generate-profiles --region eu-central-1 --sso-start-url https://your-sso-url.awsapps.com/start
# If you already have a config file, you can omit the flag:
asp-eks generate-profilesasp-eks use <profile-name>If credentials are expired, asp-eks will automatically run aws sso login --profile <profile> and retry — no need to login manually first.
Examples:
# Switch profile and update kubeconfig
asp-eks use my-profileBecause a subprocess cannot modify the parent shell's environment directly, the recommended way to also set AWS_PROFILE in your current shell is via a shell function in your .zshrc or .bashrc:
# ~/.zshrc
aeks() {
asp-eks "$@"
[[ "$1" == "use" ]] && export AWS_PROFILE="$2"
}Note: The name
aspis taken by the oh-my-zshawsplugin, henceaeks.
This wrapper supports all commands:
aeks use my-profile # switches profile, updates kubeconfig, exports AWS_PROFILE
aeks list # lists available profiles- Visit the releases page: https://github.com/eimarfandino/asp-eks/releases
- Download the appropriate binary for your operating system
# Make the binary executable
chmod +x asp-eks
# Move to your PATH
sudo mv asp-eks /usr/local/bin/# Set your GitLab token first
export GITLAB_TOKEN=your_token_here
# Download and run the installation script
curl -fsSL --header "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/69875845/repository/files/install.sh/raw | bashThe script will automatically:
- Detect your operating system (macOS or Linux)
- Detect your processor architecture (Intel x86_64 or Apple Silicon arm64)
- Download the appropriate binary from the latest GitLab release
- Install it to
/usr/local/bin/
Prerequisites for one-liner:
curlinstalledunzipinstalledGITLAB_TOKENenvironment variable set with your GitLab personal access token
To set up your GitLab token:
- Create a personal access token in GitLab with
read_apiandread_repositoryscopes - Export it:
export GITLAB_TOKEN=your_token_here
git clone https://github.com/eimarfandino/asp-eks.git
cd asp-eks
go build -o asp-eks
sudo mv asp-eks /usr/local/bin/brew tap eimarfandino/tap https://github.com/eimarfandino/homebrew-tap.git
brew install eimarfandino/tap/asp-eksTo upgrade:
brew upgrade eimarfandino/tap/asp-eksVerify:
asp-eks --help-h, --help: Display help information for asp-eks
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Eimar Fandino - Initial work