Created
March 21, 2016 17:49
-
-
Save a-h/6b7f7eb53b40754e3f18 to your computer and use it in GitHub Desktop.
Configure Boto Environment Variables
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
| echo "AWS_ACCESS_KEY " $AWS_ACCESS_KEY | |
| echo "AWS_ACCESS_KEY_ID " $AWS_ACCESS_KEY_ID | |
| echo "AWS_SECRET_KEY " $AWS_SECRET_KEY | |
| echo "AWS_SECRET_ACCESS_KEY " $AWS_SECRET_ACCESS_KEY | |
| echo "AWS_SESSION_TOKEN " $AWS_SESSION_TOKEN | |
| echo "AWS_SECURITY_TOKEN " $AWS_SECURITY_TOKEN |
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/python-pip | |
| import sys | |
| import json | |
| def main(args): | |
| if len(args) < 0: | |
| print("Pass the filename of the JSON file containing the credentials.") | |
| return | |
| with open(args[0], "r") as f: | |
| values = json.load(f) | |
| aws_access_key = values["Credentials"]["AccessKeyId"] | |
| aws_secret_key = values["Credentials"]["SecretAccessKey"] | |
| aws_session_token = values["Credentials"]["SessionToken"] | |
| print("export AWS_ACCESS_KEY='" + aws_access_key + "'") | |
| print("export AWS_ACCESS_KEY_ID='" + aws_access_key + "'") | |
| print("export AWS_SECRET_KEY='" + aws_secret_key + "'") | |
| print("export AWS_SECRET_ACCESS_KEY='" + aws_secret_key + "'") | |
| print("export AWS_SESSION_TOKEN='" + aws_session_token + "'") | |
| print("export AWS_SECURITY_TOKEN='" + aws_session_token + "'") | |
| if __name__=="__main__": | |
| main(sys.argv[1:]) |
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
| #!/bin/bash | |
| . ./unset_token_environment_variables.sh | |
| aws sts assume-role --role-arn "arn:aws:iam::321241561940:role/AccountAdminProjectName" --role-session-name "SessionName" > op.json | |
| python switch_role.py op.json > variables.sh | |
| . ./variables.sh | |
| rm ./variables.sh | |
| rm ./op.json |
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
| unset AWS_ACCESS_KEY_ID | |
| unset AWS_SECRET_ACCESS_KEY | |
| unset AWS_SESSION_TOKEN | |
| unset AWS_SECURITY_TOKEN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment