yawsso
Yet Another AWS SSO - sync up AWS CLI v2 SSO login session to legacy CLI v1 credentials.
Prerequisite
- Required
Python >= 3.6 - Required AWS CLI v2
- Assume you have already setup AWS SSO for your organization
Main Use Case
- Install latest from PyPI like so:
pip install yawsso
- Do your per normal SSO login and, have at least one active SSO session cache:
aws sso login --profile dev
- To sync for all named profiles in config (i.e. lazy consensus), 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
- To sync for all named profiles start with prefix pattern
lab*, do:
(zsh)
yawsso -p 'lab*'
(bash)
yawsso -p lab*
- To sync for all named profiles start with
lab*as well asdevandprod, do:
yawsso -p 'lab*' dev prod
- Print help to see other options:
yawsso -h
- Then, continue per normal with your daily tools. i.e.
cdk deploy ...terraform apply ...cw ls -p dev groupsawsbw -L -P devsqsmover -s main-dlq -d main-queueecs-cli ps --cluster my-cluster
Additional Use Case
Rename Profile on Sync
- Say, you have the following profile in your
$HOME/.aws/config:
[profile dev]
sso_start_url = https://myorg.awsapps.com/start
sso_region = ap-southeast-2
sso_account_id = 123456789012
sso_role_name = AdministratorAccess
region = ap-southeast-2
output = json
cli_pager =
- You want to populate access token as, say, profile name
fooin$HOME/.aws/credentials:
[foo]
region = ap-southeast-2
aws_access_key_id = XXX
aws_secret_access_key = XXX
aws_session_token = XXX
...
- Do like so:
yawsso -p dev:foo
- Then, you can
export AWS_PROFILE=fooand usefooprofile!
Export Tokens
- Use
-eflag if you want a temporary copy-paste-able time-gated access token for an instance or external machine.
🤚 PLEASE USE THIS FEATURE WITH CARE SINCE ENVIRONMENT VARIABLES USED ON SHARED SYSTEMS CAN GIVE UNAUTHORIZED ACCESS TO PRIVATE RESOURCES:
- Please note that, it uses
defaultprofile if no additional arguments pass.
yawsso -e
export AWS_ACCESS_KEY_ID=xxx
export AWS_SECRET_ACCESS_KEY=xxx
export AWS_SESSION_TOKEN=xxx
- This use case is especially tailored for those who use
defaultprofile and, who would like to PIPE commands as follows.
aws sso login && yawsso -e | pbcopy
- Otherwise, for a named profile, do:
yawsso -p dev -e
- Or, right away export credentials into the current shell environment variables, do:
yawsso -p dev -e | source /dev/stdin
Note: ☝️ are mutually exclusive with the following 👇 auto copy into your clipboard. Choose one, a must!
- If you have
pyperclippackage installed,yawssowill copy access tokens to your clipboard instead.
yawsso -e
Credentials copied to your clipboard for profile 'default'
- You may
pip install pyperclipor, together withyawssoas follows.
pip install 'yawsso[all]'
Login
- You can also use
yawssosubcommandloginto SSO login then sync all in one go.
🙋♂️ NOTE: It uses
defaultprofile if optional argument--profileis absent
yawsso login -h
yawsso login
- Otherwise you can pass the login profile as follows:
yawsso login --profile dev
- Due to lazy consensus design,
yawssowill sync all named profiles once SSO login has succeeded. If you'd like to sync only upto this login profile then use--thisflag to limit as follows.
👉 Login using default profile and sync only upto this default profile
yawsso login --this
👉 Login using named profile dev and sync only upto this dev profile
yawsso login --profile dev --this
👉 Login using named profile dev and sync as foo. See above for more details on renaming, limited to one profile.
yawsso login --profile dev:foo
Login then Export token
- Exporting access token also support with login subcommand as follows:
👉 Login using default profile, sync only upto this default profile and, print access token
yawsso login -e
👉 Login using named profile dev, sync only upto this dev profile and, print access token
yawsso login --profile dev -e
Develop
- Create virtual environment, activate it and then:
make install
make test
python -m yawsso --trace version
- Create issue or pull request welcome
License
MIT License
Metadata
Release files for yawsso 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yawsso-0.7.1.tar.gz | 13.3 kB | Without provenance | Details for yawsso-0.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yawsso-0.7.1-py3-none-any.whl | Python 3 | none | any | Details for yawsso-0.7.1-py3-none-any.whl |
Total release size: 24.8 kB
Release files / yawsso-0.7.1.tar.gz
| Download URL | yawsso-0.7.1.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d95732440ba01f95be1469c6d8fac746fa321cfba8182b1a0458a9471340fa62
|
|
BLAKE2b-256 checksum How to use checksums |
04430aa063c779ed6134d710a0331558432dbaa1954b70ce3e86f2b353cd6f0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.6
|
Release files / yawsso-0.7.1-py3-none-any.whl
| Download URL | yawsso-0.7.1-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a68dc63e6d6e0a0bce2e7a562a5592c4d997e5eebd4f412076b059ab2d2aa3fe
|
|
BLAKE2b-256 checksum How to use checksums |
703a4766e412bbea4014cd840e426738d06d41ce84762d735c3b72187179337a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.6
|
Security for yawsso 0.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.