{"id":16840126,"url":"https://github.com/ajkerrigan/aws-sso-config-builder","last_synced_at":"2026-03-08T13:32:46.568Z","repository":{"id":65721143,"uuid":"598124225","full_name":"ajkerrigan/aws-sso-config-builder","owner":"ajkerrigan","description":"Generate AWS SSO named profiles for use with the AWS CLI","archived":false,"fork":false,"pushed_at":"2024-09-27T00:29:03.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T06:57:48.630Z","etag":null,"topics":["aws","aws-sso","cli","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/aws-sso-config-builder/","language":"Python","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/ajkerrigan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2023-02-06T13:02:18.000Z","updated_at":"2024-10-03T15:44:08.000Z","dependencies_parsed_at":"2024-03-13T18:28:49.237Z","dependency_job_id":"783ddfb1-9145-43b7-bc3b-eaf53a47fcd1","html_url":"https://github.com/ajkerrigan/aws-sso-config-builder","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"ed5ef9916536b7dfcda252ce917f73aef047be77"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajkerrigan%2Faws-sso-config-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajkerrigan%2Faws-sso-config-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajkerrigan%2Faws-sso-config-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajkerrigan%2Faws-sso-config-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajkerrigan","download_url":"https://codeload.github.com/ajkerrigan/aws-sso-config-builder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351266,"owners_count":21089268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-sso","cli","python"],"created_at":"2024-10-13T12:35:32.829Z","updated_at":"2026-03-08T13:32:41.537Z","avatar_url":"https://github.com/ajkerrigan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS SSO Config Builder \u003c!-- omit in toc --\u003e\n\n[![PyPI - Version](https://img.shields.io/pypi/v/aws-sso-config-builder.svg)](https://pypi.org/project/aws-sso-config-builder)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aws-sso-config-builder.svg)](https://pypi.org/project/aws-sso-config-builder)\n\n-----\n\n**Table of Contents**\n\n- [The Gist](#the-gist)\n- [Why](#why)\n  - [...would someone use this?](#would-someone-use-this)\n  - [...did I publish this?](#did-i-publish-this)\n  - [...the focus on aws-vault?](#the-focus-on-aws-vault)\n- [Installation](#installation)\n  - [Into the Active Python Environment](#into-the-active-python-environment)\n  - [With Pipx](#with-pipx)\n  - [With Pipx Alongside Cog](#with-pipx-alongside-cog)\n- [Usage](#usage)\n  - [CLI](#cli)\n    - [Quickstart with Defaults](#quickstart-with-defaults)\n    - [More Options](#more-options)\n  - [Python](#python)\n    - [Quickstart with Defaults](#quickstart-with-defaults-1)\n    - [Usage with Cog](#usage-with-cog)\n- [Extras](#extras)\n  - [Fish Convenience Functions](#fish-convenience-functions)\n- [License](#license)\n\n## The Gist\n\nThis tool generates AWS CLI configuration blocks for use with AWS IAM Identity Center\n(formerly AWS SSO):\n\n- [Named profiles](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)\n- [SSO Session](https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-token.html#sso-configure-profile-token-auto-sso-session)\n\n## Why\n\n### ...would someone use this?\n\nIf they:\n\n- Have access to a large or shifting set of accounts and roles through AWS SSO\n- Don't already have tools in place to generate and maintain their named profiles\n  - There are a few of these, I remember [aws-sso-util](https://github.com/benkehoe/aws-sso-util) in particular\n- Want to automatically generate/regenerate templatized blocks without interfering with manually-defined sections\n\n### ...did I publish this?\n\n- After https://github.com/99designs/aws-vault/pull/1088 got merged, I wanted to update the script I use to update my AWS CLI config\n- [Cog](https://nedbatchelder.com/code/cog/) wasn't on my radar when I started doing this stuff, but is just what I want to maintain the cleaner bits of my frankenconfig\n- I wanted an excuse to try [Hatch](https://hatch.pypa.io/) on something\n\n### ...the focus on aws-vault?\n\nFrom the user experience perspective, the biggest win is that when using my aws-vault profiles, they just work:\n\n- If I don't have an active SSO session, it pops open a browser to login without me having to manually type `aws sso login`\n- If my session credentials are missing or expired, aws-vault refreshes them behind the scenes without killing running commands\n\nBut to be fair, a lot of why I use aws-vault is habit. If you're not already using it, I'm not here to sell it to you.\n\n## Installation\n\n### Into the Active Python Environment\n\n```console\npip install aws-sso-config-builder\n```\n\n### With Pipx\n\n```console\npipx install aws-sso-config-builder\n```\n\n### With Pipx Alongside Cog\n\nUseful to support [Usage with Cog](#usage-with-cog).\n\n```console\npipx install cogapp\npipx inject cogapp aws-sso-config-builder\n```\n\n## Usage\n\nGenerate AWS CLI `sso-session` and `profile` blocks based on the accounts\nand roles granted by your AWS SSO login(s).\n\nUse as a CLI tool or from Python.\n\n### CLI\n\n#### Quickstart with Defaults\n\n```console\ngenerate-sso-profiles -s my-sso-directory-name\n```\n\nThis will generate `sso-session` and `profile` blocks\n\n\n#### More Options\n\n\u003c!---[[[cog\nimport click\nimport cog\nfrom aws_sso_config_builder.gen_config import cli\n\nctx = click.Context(cli, info_name='generate-sso-profiles')\ncog.outl(f'''\n```console\n{ctx.get_help()}\n```\n''')\n]]]--\u003e\n\n```console\nUsage: generate-sso-profiles [OPTIONS]\n\nOptions:\n  -s, --sso-directories TEXT     SSO directory names, which will be used:\n\n                                 - To define \"sso-session\" config blocks\n                                 - To build an SSO start URL  [required]\n  -t, --profile-template TEXT    An AWS CLI profile block template with\n                                 {placeholders} for profile values\n\n                                 Supported placeholder variables:\n                                 - profile_name\n                                 - account_name\n                                 - account_id\n                                 - role_name\n                                 - sso_session\n\n                                 ...and any other \"key\" provided in --extra-\n                                 vars\n  -e, --extra-vars TEXT          Custom variables in the form \"key=value\" that\n                                 can be referenced with {placeholders} in a\n                                 profile template.\n  -r, --regex-replacements TEXT  Regex replacements to perform on generated\n                                 profile names, in the form\n                                 'pattern,replacement'\n  --help                         Show this message and exit.\n```\n\n\u003c!---[[[end]]]--\u003e\n\n### Python\n\n#### Quickstart with Defaults\n\n```python\nfrom aws_sso_config_builder.gen_config import generate_config_blocks\n\nprint(generate_config_blocks(sso_directories=[\"my-sso-directory-name\"]))\n```\n\n#### Usage with Cog\n\nUse [Cog](https://nedbatchelder.com/code/cog/) to dynamically generate or replace specific sections inside an `~/.aws/config` file without touching manually-maintained blocks.\n\nThis invocation specifies:\n\n- A custom profile template, including:\n  - `credential_process` profiles for use with [aws-vault](https://github.com/99designs/aws-vault)\n  - additional settings defined for each profile\n- Some regex replacements to adjust the generated profile name\n\nAdd this Cog block to a new or existing `~/.aws/config` file:\n\n```console\n# [[[cog\n# import cog\n# from aws_sso_config_builder.gen_config import generate_config_blocks\n#\n# cog.outl(generate_config_blocks(\n#     sso_directories=[\"home\", \"work\"],\n#     profile_template=\"\"\"\n#         [profile {profile_name}-sso]\n#         sso_session = {sso_session}\n#         sso_account_id = {account_id}\n#         sso_role_name = {role_name}\n#         output = json\n#         region = us-east-2\n#\n#         [profile {profile_name}]\n#         credential_process = {aws_vault_path} exec --json {profile_name}-sso\n#         output = json\n#         region = us-east-2\n#     \"\"\",\n#     regex_replacements={\n#         \"Production\": \"prod\",\n#         \"Sandbox\": \"sbx\"\n#     },\n#     aws_vault_path=\"/home/aj/go/bin/aws-vault\",\n# ))\n# ]]]\n# [[[end]]]\n```\n\nAnd then run:\n\n```console\ncog -r ~/.aws/config\n```\n\nNote that this depends on having Cog and aws-sso-config-builder installed in the same Python\nenvironment. See also [Installation with Pipx Alongside Cog](#with-pipx-alongside-cog) above.\n\n## Extras\n\n### Fish Convenience Functions\n\nThese are probably specific to my environment, but sharing them because someone else might find them useful.\n\nI use a fish convenience function ([asp](./extras/fish/functions/asp.fish)) to search or switch among AWS profiles. I'm reasonably sure that it was inspired at some point by a function of the same name in the [aws plugin for oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/aws/aws.plugin.zsh).\n\nInvoking `asp` with no arguments opens an [fzf](https://github.com/junegunn/fzf/) search of available profiles. But the command also supports tab completion with [this completion script](./extras/fish/completions/asp.fish).\n\n\n## License\n\n`aws-sso-config-builder` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajkerrigan%2Faws-sso-config-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajkerrigan%2Faws-sso-config-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajkerrigan%2Faws-sso-config-builder/lists"}