Skip to content

About

Generate an ~/.aws/config after authenticating with AWS IAM Identity Center and authorizing our application.

Topics

Resources

Stars

11 stars

Watchers

2 watching

Forks

Repository files navigation

AwsSsoConfigGenerator

Tool to generate an AWS config file (​~/.aws/config) (our file is saved to ​~/.aws/config.generated) after authenticating and authorizing AWS SSO IAM Identity Center.

images/aws-sso-config-generator-pkce.gif

Downloads

Available downloads for macOS (x86 and m series), linux (x86 and arm64) and windows.

Install with mise or aqua

This repository ships an aqua registry at its root (registry.yaml). Until the package is merged into the official aqua-registry, you can install directly from this repo’s registry by pointing mise or aqua at it. Both tools download the release binary for your OS/arch and verify it against the release’s aws-sso-config-generator-checksums.txt.

With mise (set the registry via the MISE_AQUA_REGISTRIES env var, or persist it under [settings] / aqua.registries in your config):

MISE_AQUA_REGISTRIES=https://github.com/djgoku/aws-sso-config-generator \
  mise use -g "aqua:djgoku/aws-sso-config-generator@latest"

# or pin a specific version
MISE_AQUA_REGISTRIES=https://github.com/djgoku/aws-sso-config-generator \
  mise use -g "aqua:djgoku/aws-sso-config-generator@0.4.1"

With aqua directly, add the registry and package to your aqua.yaml:

registries:
  - name: djgoku
    type: github_content
    repo_owner: djgoku
    repo_name: aws-sso-config-generator
    ref: main            # a tag/commit is safer than a branch
    path: registry.yaml
packages:
  - name: djgoku/aws-sso-config-generator@0.4.1
    registry: djgoku

Then run aqua install. (Both remote forms resolve the file from the default branch, so they work once registry.yaml is present there.)

Verify with packslip

Releases after 0.4.2 ship packslip.sigstore.json, a signed list of every binary’s digest, platform, and command name. This repo’s release workflow signs it.

With mise 2026.9.2 or later, this installs the binary for your platform. mise first verifies the signature, project, version, and digest. (mise holds new releases back 24 hours by default via minimum_release_age.)

mise use -g packslip:github.com/djgoku/aws-sso-config-generator

To verify a manual download with the packslip CLI, download the binary and packslip.sigstore.json from the same release, then run the command below. ps1_iiyjlwltyd4utkfftgvbpsxwvq is this repository’s signer fingerprint. With it, verify fails for a bundle signed by any other repository, including one that later takes this repository’s name.

packslip verify packslip.sigstore.json \
  --pin ps1_iiyjlwltyd4utkfftgvbpsxwvq \
  --artifact aws-sso-config-generator-macos-m1

macOS

A mise install needs no extra steps. If you download the macOS binary with a browser, macOS quarantines it, and running it shows this popup:

Apple could not verify “aws-sso-config-generator” is free of malware that may harm your Mac or compromise your privacy.

./images/macos-popup.png

Allow executable to not be quarantined

Verify the binary with packslip first, as in Verify with packslip above. Then clear the quarantine flag and make the binary executable:

xattr -dr com.apple.quarantine ~/aws-sso-config-generator
chmod +x ~/aws-sso-config-generator

More information here https://apple.stackexchange.com/a/436677

Usage

Note: if no parameters are passed user will be prompted for ~region~ and ~start_url~.

Example call of aws-sso-config-generator where AWS access portal is in us-west-2 with a url of https://​<example>.awsapps.com/start/#/.

aws-sso-config-generator --region us-west-2 --sso-region us-east-1 --start-url https://<example>.awsapps.com/start/#/
aws-sso-config-generator -r us-west-2 --sso-region us-east-1 -u https://<example>.awsapps.com/start/#/

Parameters

OptionTypeExampleDescriptionDefault
–sso-regionstring–sso-region us-west-2Region where AWS resources are hosted.
–region or -rstring-r us-west-2Region where AWS access portal is hosted.
–start-url or -ustring-u https://<example>.awsapps.com/start/#/The URL for the AWS access portal
–help or -hN/A-hHelp menu
–template or -tstring-t ~/.aws/config.template.jsonJSON template file to re-kap accounts and roles~/.aws/config.template.json
–out or -ostring-o ~/.aws/config.generatedOutput file for generated AWS config file~/.aws/config.generated
–sso-session-namestring–sso-session-name my-ssoSSO Session name used in IAM Identity Center config (non-legacy).my-sso
–device-codeN/A–device-codeWill use the device code XXX-XXX instead of PKCE

Example IAM Identity Center Config (~/.aws/config.generated)

More about this config type: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html

~/.aws/config.generated:

# config generated via https://github.com/djgoku/aws-sso-config-generator
#
# This requires AWS CLI v2
#
# 1. log into aws sso via `aws sso login --profile use-any-profile-name`
# 2. validate `AWS_PROFILE=use-any-profile-name aws sts get-caller-identity`

# AWS_CONFIG_FILE=~/.aws/config.generated AWS_PROFILE=1111111-ReadOnly aws sts get-caller-identity
[profile 1111111-ReadOnly]
sso_session = my-sso
sso_account_id = 1111111
sso_role_name = ReadOnly
region = us-west-2
output = json

# AWS_CONFIG_FILE=~/.aws/config.generated AWS_PROFILE=1111111-ReadOnly aws sts get-caller-identity
[profile 1111111-ReadOnly]
sso_session = my-sso
sso_account_id = 1111111
sso_role_name = ReadOnly
region = us-west-2
output = json

[sso-session my-sso]
sso_region = us-east-2
sso_start_url = https://<example>.awsapps.com/start/#/
sso_registration_scopes = sso:account:access

Example Legacy Config (~/.aws/config.generated-legacy)

~/.aws/config.generated:

# config generated via https://github.com/djgoku/aws-sso-config-generator
#
# This requires AWS CLI v2
#
# 1. log into aws sso via `aws sso login --profile use-any-profile-name`
# 2. validate `AWS_PROFILE=use-any-profile-name aws sts get-caller-identity`

# AWS_CONFIG_FILE=~/.aws/config.generated-legacy AWS_PROFILE=1111111-ReadOnly aws sts get-caller-identity
[profile 1111111-ReadOnly]
sso_start_url = https://<example>.awsapps.com/start/#/
sso_region = us-east-2
sso_account_id = 1111111
sso_role_name = ReadOnly
region = us-west-2
output = json

# AWS_CONFIG_FILE=~/.aws/config.generated-legacy AWS_PROFILE=1111111-ReadOnly aws sts get-caller-identity
[profile 1111111-ReadOnly]
sso_start_url = https://<example>.awsapps.com/start/#/
sso_region = us-east-2
sso_account_id = 1111111
sso_role_name = ReadOnly
region = us-west-2
output = json

Example JSON Template (~/.aws/config.template.json)

In the template.json structure, the values under the accounts and roles keys are used to replace their respective keys during config generation. For example:

  • "111111" in accounts will be replaced with "dev"
  • "Admin" in roles will be replaced with "" (empty string)

~/.aws/config.template:

{
  "accounts": {
    "111111": "dev",
    "222222": "uat",
    "333333": "prod"
  },
  "roles": {
    "Admin": "",
    "ReadOnly": "read"
  }
}

Development

  1. Clone repository
  2. mise install (installs the toolchain, hex/rebar, and node deps via hooks)
  3. mise run test - fetch deps, run tests, check formatting

Other tasks:

  • mise run do-all - full local release build (all Burrito targets)

Note (testing Burrito builds): the wrapper extracts its payload to ~~/Library/Application Support/.burrito/<app>_erts-<erts>_<version>~ and reuses it on every launch. A rebuilt binary at the same version will keep running the old extracted payload - run ./burrito_out/<binary> maintenance uninstall before re-testing a rebuild.

  • mise run escript - build the escript variant
  • mise run gen-workflows - regenerate GitHub Actions YAML from the Pkl sources
  • mise run version-info-only - print the current mix.exs version

PKCE and Device Code Process diagrams for AWS CLI and aws-sso-config-generator

MethodMermaid Diagram
PKCE via aws-sso-config-generatorimages/aws-sso-config-generator-authorization-code-pkce-flow.md
PKCE via aws cliimages/aws-sso-auth-code-pkce-flow.md
Device Code via aws-sso-config-generatorimages/aws-sso-config-generator-device-code-flow.md
Device Code via aws cliimages/aws-sso-device-code-flow.md

FAQ

Why am I seeing an old version of an aws-sso-config-generator?

You might need to clean-up old resources from a previous version and re-run the application.

./burrito_out/aws_sso_config_generator maintenance uninstall
[w] This will uninstall the application runtime for this Burrito binary!
[?] Please confirm this action [y/n]: y
y
[i] Deleting directory: /home/devbox/.local/share/.burrito/aws_sso_config_generator_erts-15.2.2_0.1.0
[i] Uninstall complete!
[i] Quitting.

How do these binaries work?

We are using burrito which packages everything required to run the application into a self-extracting executable. Once ran the application is extracted and then ran.

References

Elixir

Other

AWS

About

Generate an ~/.aws/config after authenticating with AWS IAM Identity Center and authorizing our application.

Topics

Resources

Stars

11 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages