{"id":32026661,"url":"https://github.com/lakipn/aws-profile-switcher","last_synced_at":"2026-04-05T08:32:49.240Z","repository":{"id":318668941,"uuid":"1072264120","full_name":"lakipn/aws-profile-switcher","owner":"lakipn","description":"A simple, interactive AWS profile switcher that automatically handles both MFA-enabled profiles and AWS SSO profiles. No more manually setting environment variables or remembering complex commands!","archived":false,"fork":false,"pushed_at":"2025-10-15T12:21:38.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-03T16:04:09.120Z","etag":null,"topics":["aws","aws-cli","aws-mfa","aws-profile","aws-profiles","aws-sso","bash","cli-tool","developer-tools","homebrew","homebrew-formula","shell","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lakipn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-08T13:35:00.000Z","updated_at":"2025-10-15T12:27:14.000Z","dependencies_parsed_at":"2025-10-08T15:27:41.736Z","dependency_job_id":"b2fbde68-f37e-4fb6-ac37-e0edaee2ca6b","html_url":"https://github.com/lakipn/aws-profile-switcher","commit_stats":null,"previous_names":["lakipn/aws-profile-switcher"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lakipn/aws-profile-switcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakipn%2Faws-profile-switcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakipn%2Faws-profile-switcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakipn%2Faws-profile-switcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakipn%2Faws-profile-switcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lakipn","download_url":"https://codeload.github.com/lakipn/aws-profile-switcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakipn%2Faws-profile-switcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31430009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T08:13:15.228Z","status":"ssl_error","status_checked_at":"2026-04-05T08:13:11.839Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-cli","aws-mfa","aws-profile","aws-profiles","aws-sso","bash","cli-tool","developer-tools","homebrew","homebrew-formula","shell","zsh"],"created_at":"2025-10-16T14:33:14.833Z","updated_at":"2026-04-05T08:32:49.229Z","avatar_url":"https://github.com/lakipn.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Profile Switcher\n\n[![Homebrew](https://img.shields.io/badge/Homebrew-tap-orange?logo=homebrew)](https://github.com/lakipn/homebrew-tap)\n[![GitHub release](https://img.shields.io/github/v/release/lakipn/aws-profile-switcher)](https://github.com/lakipn/aws-profile-switcher/releases)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA simple, interactive AWS profile switcher that automatically handles both MFA-enabled profiles and AWS SSO profiles. No more manually setting environment variables or remembering complex commands!\n\n## Features\n\n- 🔄 **Automatic profile detection** - Discovers all your AWS profiles automatically\n- 🔐 **MFA Support** - Integrates with `aws-mfa` for MFA-enabled profiles\n- 🚀 **SSO Support** - Handles AWS SSO login/logout seamlessly\n- 🎯 **Smart switching** - Automatically logs out when switching between SSO profiles\n- ⚡ **Environment variables** - Automatically sets `AWS_PROFILE` in your current shell\n- 🔍 **Credential validation** - Checks if credentials are expired before use\n\n## Prerequisites\n\n1. **AWS CLI v2** - [Installation guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)\n2. **Bash or Zsh shell** - Most Unix systems have these by default\n3. **aws-mfa** (for MFA profiles) - Install with: `pip install aws-mfa`\n\n### Supported Platforms\n\n- ✅ **Linux** (all distributions)\n- ✅ **macOS**\n- ✅ **BSD systems** (FreeBSD, OpenBSD, NetBSD)\n- ✅ **WSL on Windows**\n- ✅ **Unix-like systems** with bash or zsh\n\n### Supported Shells\n\n- ✅ **Bash** (4.0+)\n- ✅ **Zsh**\n- ✅ **Fish** (with special installer support)\n- ⚠️ **Other shells** - basic functionality via direct script execution\n\n## Installation\n\n### Homebrew (Recommended)\n\n```bash\nbrew tap lakipn/tap\nbrew install awsinit\n```\n\nAfter installation, add the wrapper function to your shell config:\n\n**For Bash** (`~/.bashrc` or `~/.bash_profile`):\n```bash\nsource /opt/homebrew/opt/awsinit/awsinit-wrapper.sh\n```\n\n**For Zsh** (`~/.zshrc`):\n```bash\nsource /opt/homebrew/opt/awsinit/awsinit-wrapper.sh\n```\n\n**For Fish** (`~/.config/fish/config.fish`):\nSee the fish function setup in the installer script or create manually.\n\n### Quick Install (From Source)\n\n```bash\ngit clone https://github.com/lakipn/aws-profile-switcher.git\ncd aws-profile-switcher\n./install.sh\n```\n\n### Manual Install\n\n1. Copy `awsinit` to `~/bin/` and make it executable:\n\n   ```bash\n   mkdir -p ~/bin\n   cp awsinit ~/bin/awsinit\n   chmod +x ~/bin/awsinit\n   ```\n\n2. Add `~/bin` to your PATH in your shell config file (`~/.zshrc` or `~/.bashrc`):\n\n   ```bash\n   echo 'export PATH=\"$HOME/bin:$PATH\"' \u003e\u003e ~/.zshrc\n   ```\n\n3. Copy the wrapper function:\n\n   ```bash\n   cp awsinit-wrapper.sh ~/awsinit-wrapper.sh\n   ```\n\n4. Source the wrapper in your shell config:\n\n   ```bash\n   echo 'source ~/awsinit-wrapper.sh' \u003e\u003e ~/.zshrc\n   ```\n\n5. Reload your shell:\n   ```bash\n   source ~/.zshrc\n   ```\n\n## Usage\n\nSimply run:\n\n```bash\nawsinit\n```\n\nThe tool will:\n\n1. Display all available AWS profiles with their types (SSO/MFA/Keys)\n2. Let you select which profile to switch to\n3. Handle authentication (MFA code entry or SSO browser login)\n4. Set the `AWS_PROFILE` environment variable automatically\n5. Show your current AWS identity\n\n### Example Output\n\n```\nℹ Select AWS account to switch to:\n\n1. default (MFA/Keys)\n2. company-dev (SSO)\n3. company-prod (SSO)\n4. personal (MFA/Keys)\n\nEnter your choice (1-4): 2\nℹ Selected profile: company-dev\nℹ Detected SSO profile: company-dev\nℹ Running aws sso login...\n✓ SSO login successful for company-dev\n✓ SSO credentials verified\n✓ Switched to profile: company-dev\n\nℹ Current AWS identity:\n-----------------------------------------\n|            GetCallerIdentity          |\n+---------+-----------------------------+\n| Account | 123456789012                |\n| Arn     | arn:aws:sts::123456789012.. |\n| UserId  | AROABC123...:john.doe       |\n+---------+-----------------------------+\n\n✓ Environment updated: export AWS_PROFILE=\"company-dev\"\n✓ AWS_PROFILE is now: company-dev\n```\n\n## Configuration\n\n### AWS Profiles Setup\n\nThe tool automatically detects your AWS profiles from `~/.aws/config` and `~/.aws/credentials`.\n\n#### For SSO Profiles\n\nConfigure SSO profiles in `~/.aws/config`:\n\n```ini\n[profile company-dev]\nsso_start_url = https://company.awsapps.com/start\nsso_region = us-east-1\nsso_account_id = 123456789012\nsso_role_name = DeveloperAccess\nregion = us-east-1\n```\n\n#### For MFA Profiles\n\nConfigure MFA profiles in `~/.aws/credentials`:\n\n```ini\n[default-long-term]\naws_access_key_id = AKIA...\naws_secret_access_key = ...\naws_mfa_device = arn:aws:iam::123456789012:mfa/YourDevice\n\n[default]\n# This will be populated by aws-mfa\n```\n\n### aws-mfa Setup\n\nFor MFA-enabled profiles, install and configure `aws-mfa`:\n\n1. Install: `pip install aws-mfa`\n2. Configure your long-term credentials with MFA device ARN (see example above)\n3. The tool will automatically call `aws-mfa` when needed\n\n## How It Works\n\n1. **Profile Detection**: Scans `~/.aws/config` for profiles and detects their type\n2. **SSO Profiles**: Profiles with `sso_start_url` are treated as SSO profiles\n3. **MFA Profiles**: Other profiles are treated as MFA/key-based profiles\n4. **Smart Authentication**:\n   - SSO: Uses `aws sso login --profile \u003cprofile\u003e`\n   - MFA: Uses `aws-mfa` for the default profile\n   - Keys: Direct credential usage for named profiles\n5. **Environment Management**: Automatically sets/unsets `AWS_PROFILE` in your current shell\n\n## Troubleshooting\n\n### Command not found\n\n- Make sure `~/bin` is in your PATH: `echo $PATH | grep \"$HOME/bin\"`\n- Reload your shell or restart terminal\n- On some systems, you may need to log out and back in\n\n### Shell-specific issues\n\n#### Bash\n\n- Try: `source ~/.bashrc` or `source ~/.bash_profile`\n- On macOS, you may need to use `~/.bash_profile` instead of `~/.bashrc`\n\n#### Zsh\n\n- Try: `source ~/.zshrc`\n- If using Oh My Zsh, ensure no conflicts with plugins\n\n#### Fish\n\n- The installer creates a native fish function\n- Try: `source ~/.config/fish/config.fish`\n\n### Platform-specific issues\n\n#### macOS\n\n- You may need to restart Terminal.app for PATH changes\n- Ensure you have bash installed: `bash --version`\n\n#### Linux\n\n- Different distributions may use different default shells\n- Try: `echo $SHELL` to see your current shell\n\n#### WSL\n\n- Make sure you're using a Linux-style path: `/home/user/bin`\n- Windows paths won't work with the Unix-style installer\n\n### aws-mfa not found\n\n- Install with: `pip install aws-mfa`\n- On some systems: `pip3 install aws-mfa`\n- Ensure Python pip is in your PATH\n\n### SSO login fails\n\n- Check your SSO configuration in `~/.aws/config`\n- Ensure you have access to the AWS account/role\n- Try running `aws sso login --profile \u003cprofile\u003e` manually\n- Check if your browser is blocking the SSO popup\n\n### Environment variables not set\n\n- Make sure you're using the wrapper function (sourced `awsinit-wrapper.sh`)\n- For direct script usage: `~/bin/awsinit` and manually run the export command shown\n- Try reloading your shell configuration\n\n### Permission denied\n\n- Ensure the script is executable: `chmod +x ~/bin/awsinit`\n- Check file ownership: `ls -la ~/bin/awsinit`\n\n### Colors not working\n\n- Your terminal may not support ANSI colors\n- Try a different terminal emulator\n- The functionality will work without colors\n\n## Contributing\n\nContributions are welcome! Please feel free to submit issues and pull requests.\n\n## License\n\nMIT License - see LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flakipn%2Faws-profile-switcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flakipn%2Faws-profile-switcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flakipn%2Faws-profile-switcher/lists"}