Created
September 14, 2020 01:44
-
-
Save autch/e68e2fd54e953640a83e93f65fa919e4 to your computer and use it in GitHub Desktop.
show AWS credentials from standard configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import boto3 | |
| session = boto3.Session() | |
| cred = session.get_credentials().get_frozen_credentials() | |
| env = { | |
| 'AWS_PROFILE': session.profile_name, | |
| 'AWS_DEFAULT_REGION': session.region_name, | |
| 'AWS_ACCESS_KEY_ID': cred.access_key, | |
| 'AWS_SECRET_ACCESS_KEY': cred.secret_key, | |
| 'AWS_SESSION_TOKEN': cred.token | |
| } | |
| for k, v in [(k, v) for k, v in env.items() if v is not None]: | |
| print("export {key}=\"{value}\"".format(key=k, value=v)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment