Adapted from this script.
This script will scrape your roles from AWS SSO and create a AWS CLI v2 config file for you.
- Python 3.7.5 or above
- AWS CLI v2
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt
For further development -
$ pip install -r requirements-dev.txt
- Clone this repository
- Copy and paste the AWS SSO primary profile credentials from the
sample_sso_config
profile to your~/.aws/config
file - Login to AWS SSO
aws sso login --profile primary
- Execute the script
python create_sso_config.py
- Transfer contents of newly generated
sso_config
into your~/.aws/config
file
The script relies on a couple of things:
- That you have
aws cli v2
installed,python3
installed andboto3
library installed for python. - That you have configured your primary SSO profile
[profile primary]
in~/.aws/config
file - That you have already logged into AWS SSO using
aws sso login --profile primary
.
Boto3 SDK for SSO: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sso.html
AWS CLI v2 SSO configuration: https://docs.amazonaws.cn/en_us/cli/latest/userguide/cli-configure-sso.html
AWS CLI V2 announcement post: https://aws.amazon.com/blogs/developer/aws-cli-v2-is-now-generally-available/