Created
January 15, 2020 21:53
-
-
Save alevene/4d2564ad5b7faf4ddb7e859e1a499f5e to your computer and use it in GitHub Desktop.
Load okta session details into .aws/credentials
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
| """ | |
| Get AWS creds via Okta --> generate .aws/credentials.idea | |
| Backup current credentials file | |
| Take [idea_jdbc] profile from .aws/credentials.idea and append to .aws/credentials | |
| """ | |
| import datetime | |
| import os | |
| import shutil | |
| import sys | |
| import tempfile | |
| if __name__ == '__main__': | |
| os.system('/Users/alex.levene/workspace/airflow-install/.mine/push_aws_creds') | |
| dt = str(datetime.datetime.now().strftime('%Y%m%d')) | |
| cred_file = sys.argv[1] | |
| append_file = sys.argv[2] | |
| shutil.copy(cred_file, cred_file + '.' + dt) | |
| tf = tempfile.NamedTemporaryFile(mode='w', delete=False) | |
| tfile_name = tf.name | |
| with open(cred_file) as f: | |
| for l in f: | |
| if 'idea_jdbc' not in l: | |
| tf.write(l) | |
| else: | |
| break | |
| with open(append_file) as f: | |
| for l in f: | |
| tf.write(l) | |
| tf.close() | |
| shutil.copy(tfile_name, cred_file) | |
| os.remove(tfile_name) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this to use Athena JDBC via driver com.simba.athena.jdbc42.Driver