aws-sso-cred-restore
AWS SSO cred restore is a simple script to make it easier to use AWS Single Sign On credentials with tools that don't understand the sso entries in an AWS profile.
Let's imagine:
-
You work with Terraform.
-
Your company uses AWS SSO, and you use aws-sso-util to easily get temporary credentials for all accounts.
-
Your terraform modules located in the private s3 bucket
-
You make
terraform init
and got ErrorFailed to download module
It means that terraform trying to find aws_access_key_id
and aws_secret_access_key
in the ~/.aws/credentials
file based on your profile but can't due to aws-sso-util won't add these credentials to this file.
You can use aws-sso-cred-restore
to solve this problem. It will get temporary credentials and set them to ~/.aws/credentials
How to install
Pip
pip3 install aws-sso-cred-restore
From source
You can also install this tool manually from the GitHub
How to use
-
Connect to the SSO through aws-sso-util
-
Set right AWS profile for your terraform where your private modules located through asp
asp 124295726813_BOOK-PlatformManagement
- Run
aws-sso-cred-restore
aws-sso-cred-restore --profile 124295726813_BOOK-PlatformManagement
NOTE: If you open the ~/.aws/credentials
file, you will find the exported credentials.
[124295726813_BOOK-PlatformManagement]
aws_access_key_id = ABSDF2A34ESVEJSRU
aws_secret_access_key = JX/+iQqwquIhjwZ9ADi6rW9w2PqOTV864VQChzvR
aws_session_token = IQoJb3JpZ2luX2VjEPf//////////wEaCXVzLWVhc3QtMSJHMEUCIQDa...
- Run
terraform init