Python tool for generating AWS SSO configuration and directory structure
Project description
SSO Config Generator
A Python CLI tool for generating AWS SSO configuration and directory structures.
Overview
SSO Config Generator is a standalone Python tool that simplifies AWS SSO configuration management by:
- Generating properly configured AWS CLI config files
- Creating directory structures that mirror your AWS Organization
- Setting up environment files for easy role switching using
direnv
Installation
You can install SSO Config Generator using pip:
pip install sso-config-generator
Prerequisites
- Python 3.8 or higher
- AWS CLI v2 configured with:
- Default region set in
~/.aws/configor viaAWS_DEFAULT_REGIONenvironment variable - AWS SSO configured via
aws configure sso
- Default region set in
direnv(optional, for automatic profile switching)
AWS Configuration
Before using the tool, ensure you have:
-
Set your AWS region:
# Either in ~/.aws/config [default] region = eu-west-1 # Or via environment variable export AWS_DEFAULT_REGION=eu-west-1
-
Configure AWS SSO:
# Configure SSO aws configure sso # Follow the prompts to enter: # - SSO start URL (e.g., https://your-domain.awsapps.com/start) # - SSO Region # - SSO registration scopes (accept default) # Login to SSO to create credentials aws sso login
Troubleshooting
-
"Error: You must specify a region"
- Set AWS_DEFAULT_REGION environment variable
- Or configure default region in ~/.aws/config
-
"Unable to locate credentials"
- Run
aws sso loginto refresh your SSO credentials - Ensure you've completed AWS SSO configuration with
aws configure sso - Check if your SSO session has expired (sessions typically last 8 hours)
- Run
-
"SSO session is expired"
- Run
aws sso loginto start a new session
- Run
Usage
Basic Usage
Simply run:
uvx sso-config-generator
This will:
- Create/update your AWS CLI config file (
~/.aws/config) - Generate a directory structure in the current directory + sso-name
- Create
.envrcfiles in each account directory with AdministratorAccess role - Use OU structure for directory organization (cached for performance)
The tool caches OU structure information in the same directory as your AWS config file to improve performance. When the cache exists, it will be used automatically with a notification. To rebuild the cache:
uvx sso-config-generator --rebuild-cache
Command Options
Usage: sso-config-generator [OPTIONS]
Options:
--create-directories/--no-create-directories Create a directory for each account (default: True)
--use-ou-structure/--no-use-ou-structure Create directories for each OU (default: True)
--developer-role-name NAME Role name to use for .envrc files (default: AdministratorAccess)
--rebuild-cache Force rebuild of OU structure cache
--sso-name NAME Use specified SSO name instead of extracting from SSO start URL
--create-repos-md Create repos.md files in each account directory
--skip-sso-name Do not create a directory for the SSO name (default: False)
--unified-root PATH Directory where account directories are created
(default: current directory)
If current directory is named "environment", SSO name is
automatically skipped
--validate Validate current AWS SSO configuration instead of generating
--help Show this message and exit
--version Show the version and exit
Examples
- Basic config generation (uses defaults):
uvx sso-config-generator
- Disable OU structure (flat account directories):
uvx sso-config-generator --no-use-ou-structure
- Use different role for .envrc files:
uvx sso-config-generator --developer-role-name ReadOnlyAccess
- Force rebuild of OU cache:
uvx sso-config-generator --rebuild-cache
- Specify custom root directory:
uvx sso-config-generator --unified-root ~/aws-environments
- Skip creating directories (config file only):
uvx sso-config-generator --no-create-directories
- Working in an "environment" directory (automatic behavior):
# If your current directory is named 'environment'
cd environment
uvx sso-config-generator
# This will automatically skip creating the SSO name directory
- Validate existing configuration:
uvx sso-config-generator --validate
Development
Setup Development Environment
- Clone the repository:
git clone https://github.com/easytocloud/sso-config-generator.git
cd sso-config-generator
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the package in development mode:
pip install -e .
Common Development Tasks
- Build the package:
pip install build && python -m build - Run the tool:
uvx sso-config-generator - Test changes:
./test_sso_config.sh
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sso_config_generator-1.1.1.tar.gz.
File metadata
- Download URL: sso_config_generator-1.1.1.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2489d04a322e8d96380412427483f0ca71ac74b3d8ff718531ad5442d73077d2
|
|
| MD5 |
c33158a451f5285482adc97e27c9333a
|
|
| BLAKE2b-256 |
18bee12552b4a7436596dd5fc792eaf048554c341465cc2883587efb3bc940c8
|
File details
Details for the file sso_config_generator-1.1.1-py3-none-any.whl.
File metadata
- Download URL: sso_config_generator-1.1.1-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e21c484444291d6e95e55c365edfc0a45a091147d7380c4940f4a4657973a3a
|
|
| MD5 |
5b82aef976c16f54c3f2d86a8b71afc5
|
|
| BLAKE2b-256 |
4638e2e992153d9c0372eeab5b5542d90f00266039d8a5a971e6d829f3ae707c
|