Last active
February 26, 2019 19:47
-
-
Save bzcorn/74d0000038bce5dbfa152e9b7e4f536f to your computer and use it in GitHub Desktop.
This script will take the output of an aws sts assume-role and automatically export it into your Env Vars.
This file contains 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
import sys | |
import json | |
def main(PIPED_IN): | |
""" | |
""" | |
a = json.loads(PIPED_IN) | |
env_var_values = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"] | |
sts_values = ["AccessKeyId", "SecretAccessKey", "SessionToken"] | |
for key,value in zip(env_var_values, sts_values): | |
print(f"export {key}={a['Credentials'][value]}") | |
return | |
if __name__ == "__main__": | |
PIPED_IN = "" | |
for line in sys.stdin: | |
PIPED_IN += line | |
main(PIPED_IN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment