Skip to content

curdbecker/aws-toolkit-profile-exporter

Repository files navigation

AWS Toolkit Profile Exporter

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.

Features

  • 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 via awsToolkitProfileExporter.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 variable AWS_PROFILE - see below.
  • Auto-regeneration (awsToolkitProfileExporter.autoRegenerate, default true) — the exported config is refreshed automatically whenever AWS Toolkit connections change.
  • Export on launch (awsToolkitProfileExporter.exportOnLaunch, default true) — profiles are exported automatically when VS Code starts, so your shell environment is ready to go immediately.

Requirements

  • 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).

Usage

  1. Sign in to one or more IAM Identity Center connections using the AWS Toolkit as usual.
  2. Run AWS: Export AWS Toolkit connections from the command palette, or just rely on the automatic export on launch / on connection change.
  3. Point your CLI tools at the generated config (e.g. export AWS_CONFIG_FILE=... when using the isolated or custom location). For the integrated VSCode terminal, the environment variable will be automatically set and should be available directly when opening new terminal sessions.
  4. Use --profile <account-name> as normal on AWS CLI tools. Or use AWS_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.

About

VSCode plugin for exporting authentication tokens generated by the official AWS Toolkit with other CLI tools. Quite useful for shell scripts in a devcontainer.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors