Skip to content

Instantly share code, notes, and snippets.

@alevene
Created January 15, 2020 21:53
Show Gist options
  • Select an option

  • Save alevene/4d2564ad5b7faf4ddb7e859e1a499f5e to your computer and use it in GitHub Desktop.

Select an option

Save alevene/4d2564ad5b7faf4ddb7e859e1a499f5e to your computer and use it in GitHub Desktop.
Load okta session details into .aws/credentials
"""
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)
@alevene
Copy link
Author

alevene commented Jan 15, 2020

Run this to use Athena JDBC via driver com.simba.athena.jdbc42.Driver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment