A convenient shell script for managing AWS SSO logins with interactive account and role selection using fzf.
- Interactive AWS SSO session selection
- Account and role selection with fuzzy finding
- Profile creation and management
- Region selection
- Zsh shell
Install the script with a single command:
curl -sSL https://raw.githubusercontent.com/Xmaxer/aws-login/main/install.sh | bashThis will:
- Download the
aws-login.shscript - Install it to
~/.aws-login/ - Add it to your
.zshrcfile - Source it in your current session
- Create a backup of your existing
.zshrc
-
Download the script:
curl -sSL https://raw.githubusercontent.com/Xmaxer/aws-login/main/aws-login.sh -o ~/.aws-login/aws-login.sh chmod +x ~/.aws-login/aws-login.sh
-
Add to your
.zshrc:echo 'source ~/.aws-login/aws-login.sh' >> ~/.zshrc
-
Reload your shell:
source ~/.zshrc
aws-loginThis interactive command will guide you through:
- Selecting an AWS SSO session (if multiple are configured)
- Choosing an AWS account
- Selecting a role within that account
- Picking a region for the profile
aws-login- Begins the interactive login process
Before using the script, you need to configure AWS SSO:
aws sso configureFollow the prompts to set up your SSO session with:
- SSO start URL
- SSO region
- Default client region
- Default output format
- Session Selection: Choose from configured SSO sessions
- Authentication: Automatically handles SSO login
- Account Selection: Browse available accounts with fuzzy search
- Role Selection: Choose from available roles in the selected account
- Region Selection: Pick your preferred AWS region
- Profile Creation: Automatically creates and activates the profile
The script creates profiles with the naming convention:
<session>/<account-name>/<role>/<region>
Special characters are replaced with hyphens for compatibility.
The script manages the AWS_PROFILE environment variable and saves it to ~/.zshenv for persistence across sessions.
The script will automatically prompt to install missing dependencies:
fzf- For interactive selection menusjq- For JSON processingaws- AWS CLI v2
On macOS with Homebrew, missing dependencies will be installed automatically with user confirmation.
Restart your terminal or run:
source ~/.zshrcMake sure the script is executable:
chmod +x ~/.aws-login/aws-login.shRun the initial SSO configuration:
aws sso configureInstall manually:
# macOS with Homebrew
brew install fzf jq awscli
# Ubuntu/Debian
sudo apt-get install jq
# For fzf and AWS CLI, follow their respective installation guidesTo remove the script:
-
Remove the source line from
.zshrc:sed -i '/source.*aws-login\.sh/d' ~/.zshrc
-
Remove the installation directory:
rm -rf ~/.aws-login -
Remove environment file (optional):
rm -f ~/.zshenv
Feel free to submit issues and pull requests to improve the script.
This project is open source and available under the MIT License.