Or, right away export credentials into the current shell environment variables, do:
yawsso -p dev -e | yawsso decrypt | source /dev/stdin
Note: ☝️ are mutually exclusive with the following 👇 auto copy into your clipboard. Choose one, a must!
If you have pyperclip package installed, yawsso will copy access tokens to your clipboard instead.
yawsso -e
Credentials copied to your clipboard for profile 'default'
You may pip install pyperclip or, together with yawsso as follows.
pip install 'yawsso[all]'
Login
You can also use yawsso subcommand login to SSO login then sync all in one go.
🙋♂️ NOTE: It uses default profile or AWS_PROFILE environment variable if optional argument --profile is absent
yawsso login -h
yawsso login
Otherwise you can pass the login profile as follows:
yawsso login --profile dev
Due to lazy consensus design, yawsso will sync all named profiles once SSO login has succeeded. If you'd like to sync only upto this login profile then use --this flag 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 | yawsso decrypt
👉 Login using named profile dev, sync only upto this dev profile and, print access token
yawsso login --profile dev -e | yawsso decrypt
Auto Login then Sync
Like login, you may use yawsso subcommand auto to SSO login then sync all in one go.
It will check if SSO session has expired and, if so, yawsso will attempt to auto login again.
yawsso auto -h
(either)
yawsso auto --profile dev
(or)
export AWS_PROFILE=dev
yawsso auto
Set Default
You can copy a named profile's credentials to the default profile in $HOME/.aws/credentials:
yawsso set-default dev
Or use the short alias sd:
yawsso sd dev
This is useful when the default profile has no SSO configuration but your tools rely on it.
Show Account ID
You can retrieve the sso_account_id associated with a given profile from $HOME/.aws/config:
yawsso show-account-id --profile qa
123456789012
Or use the short alias sid:
yawsso sid --profile qa
123456789012
The output is plain text, making it easy to consume in scripts or pipe into other tools:
export AWS_ACCOUNT_ID=$(yawsso sid --profile qa)
Set Region
You can also set region from the config file to the shared credentials file
Do like so:
yawsso -r -p dev
yawsso -r -p dev:foo
yawsso -r auto --profile dev
Encryption
yawsso can encrypt and decrypt some arbitrary string from stdin using ROT13 (a simple letter substitution cipher) as follows.
echo 'Hello this is a test' | yawsso encrypt
Uryyb guvf vf n grfg
echo 'Uryyb guvf vf n grfg' | yawsso decrypt
Hello this is a test
(or Pipe through some text corpus)
cat test.txt | yawsso encrypt
(or on Windows)
type test.txt | yawsso encrypt
This is the same as using trivial Unix tr command as follows.
echo 'Hello this is a test' | tr 'A-Za-z' 'N-ZA-Mn-za-m'
Uryyb guvf vf n grfg
echo 'Uryyb guvf vf n grfg' | tr 'A-Za-z' 'N-ZA-Mn-za-m'
Hello this is a test
Hence, you could also decode yawsso exported tokens using tr command, like so.
yawsso -p dev -e | tr 'A-Za-z' 'N-ZA-Mn-za-m'
Develop
Create virtual environment, activate it and then:
make install
make test
python -m yawsso --trace version