Skip to main content

Yet Another AWS SSO - sync up AWS CLI v2 SSO login session to legacy CLI v1 credentials

Project description

yawsso

Pull Request Build Status codecov.io

Yet Another AWS SSO - sync up AWS CLI v2 SSO login session to legacy CLI v1 credentials.

Do I need it?

Prerequisite

TL;DR

pip install yawsso
  • Do your per normal SSO login and, have at least one org-level SSO login session cache:
aws sso login --profile=dev
  • To sync for all named profiles (e.g. dev, prod, stag, ...), then just:
yawsso
  • To sync default profile and all named profiles, do:
yawsso --default
  • To sync default profile only, do:
yawsso --default-only
  • To sync for selected named profile, do:
yawsso -p dev
  • To sync for multiple selected named profiles, do:
yawsso -p dev prod
  • To sync for default profile as well as multiple selected named profiles, do:
yawsso --default -p dev prod
  • Use -e flag if you want a temporary copy-paste-able time-gated access token for an instance or external machine. It use default profile if no additional arguments pass. The main use case is for those who use default profile, and would like to PIPE like this aws sso login && yawsso -e | pbcopy. Otherwise for named profile, do yawsso -e -p dev.

    PLEASE USE THIS FEATURE WITH CARE SINCE ENVIRONMENT VARIABLES USED ON SHARED SYSTEMS CAN GIVE UNAUTHORIZED ACCESS TO PRIVATE RESOURCES:

yawsso -e
export AWS_ACCESS_KEY_ID=xxx
export AWS_SECRET_ACCESS_KEY=xxx
export AWS_SESSION_TOKEN=xxx
  • You can also use yawsso subcommand login to SSO login then sync all in one go:
yawsso login -h
yawsso login
yawsso login --this
yawsso login --profile dev
yawsso login --profile dev --this
  • Print help to see other options:
yawsso -h
  • Then, continue per normal with your daily tools. i.e.
    • cdk deploy ...
    • terraform ...
    • cw ls -p dev groups
    • awsbw -L -P dev

Why

AWS CLI v2 SSO login cache/store credentials is somewhat different to AWS CLI v1 i.e. no longer in ~/.aws/credentials. There are many SDK and tools still depends on this legacy ~/.aws/credentials format.

And, https://github.com/aws/aws-cli/issues/4982 in CLI repo itself!!

This tool is originally based on aws_sso.py script but take different approach and depends only on AWS CLI v2 for get-role-credentials. Well, everything else fail (including boto3) except CLI itself, so...

Someday, we won't need this anymore. But, until then this tool sync up AWS CLI v2 SSO login session to legacy format auto-magically!!

Others

If this tools is not working for you, try the following:

Develop

  • Create virtual environment and then:
pip install '.[dev,test]' .
pytest
python -m unittest
python -m yawsso --trace
  • Create issue or pull request welcome

License

MIT License

License: MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yawsso-0.4.0rc2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

yawsso-0.4.0rc2-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file yawsso-0.4.0rc2.tar.gz.

File metadata

  • Download URL: yawsso-0.4.0rc2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for yawsso-0.4.0rc2.tar.gz
Algorithm Hash digest
SHA256 dc6a0f98d29b87ae11d7adce892fc9666545c0928ea2968fab7e5db3a3fd5af3
MD5 665c6bd608fe4b89b48d1e9f9fb6a5ab
BLAKE2b-256 4faf5fd5426e9c2fa4e2912238f679f08e045ddc9072f414c5f2c19a6c7bb332

See more details on using hashes here.

File details

Details for the file yawsso-0.4.0rc2-py3-none-any.whl.

File metadata

  • Download URL: yawsso-0.4.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for yawsso-0.4.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 75ca661a95b45d917add2935a137f4c909ce37d57005efcc23290990d7f76132
MD5 776a3fc840e1ddd394358d452d64b0a4
BLAKE2b-256 8f2028112ad25bb1096cb35dacdaeaa56ce47662ebc9d61ea5c8f490cf8388d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page