A VS Code extension that exports authentication tokens generated by the official AWS Toolkit for IAM Identity Center (SSO) sessions into a standard AWS config/credentials file, so other CLI tools can reuse them. Especially handy for shell scripts running inside a devcontainer and you want to switch between multiple environments easily.
- Export AWS Toolkit connections to an AWS config file via the command
AWS: Export AWS Toolkit connections. IAM Identity Center (SSO) sessions managed by the AWS Toolkit are translated into named profiles usable by the AWS CLI, SDKs, and any tool that reads the standard AWS config. - Configurable output location through
awsToolkitProfileExporter.configLocation:isolated(default, recommended) — writes to an isolated config file managed by the extension, leaving your global AWS config untouched.custom— writes to a path you specify viaawsToolkitProfileExporter.customConfigPath.global— overwrites the config in the default location in your home directory (use with care).
- Preferred role naming via
awsToolkitProfileExporter.preferredRole(default:AdministratorAccess). When an account has the preferred role, its profile is named after the account alone; otherwise the profile is named<account name>-<role name>. These profile names can then be directly used via the AWS CLI tool environment variableAWS_PROFILE- see below. - Auto-regeneration (
awsToolkitProfileExporter.autoRegenerate, defaulttrue) — the exported config is refreshed automatically whenever AWS Toolkit connections change. - Export on launch (
awsToolkitProfileExporter.exportOnLaunch, defaulttrue) — profiles are exported automatically when VS Code starts, so your shell environment is ready to go immediately.
- VS Code >=
^1.108.1(the initial release with which I developed - works so far across updates) - The AWS Toolkit for Visual Studio Code extension (declared as an extension dependency and installed automatically).
- Sign in to one or more IAM Identity Center connections using the AWS Toolkit as usual.
- Run AWS: Export AWS Toolkit connections from the command palette, or just rely on the automatic export on launch / on connection change.
- Point your CLI tools at the generated config (e.g.
export AWS_CONFIG_FILE=...when using theisolatedorcustomlocation). For the integrated VSCode terminal, the environment variable will be automatically set and should be available directly when opening new terminal sessions. - Use
--profile <account-name>as normal on AWS CLI tools. Or useAWS_PROFILE=<account name>to select between different profiles on the fly for shell scripts running multiple AWS commands or set it as fixed environment variable as needed.