Last active
December 29, 2015 11:49
-
-
Save vladistan/7666753 to your computer and use it in GitHub Desktop.
Retrieve the aws key and secret from .awsAuth file. More information on .awsAuth is here https://code.google.com/p/aws4c/wiki/DevGuide
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
# coding=utf-8 | |
import os | |
def get_aws_key(key_id): | |
""" | |
Retrieve the aws key and secret from .awsAuth file. | |
Your awsAuth file should contain the following lines for the tests to work. | |
test1:test_key_1:test_secret_1 | |
test2:test_key_2:test_secret_2 | |
More information onf .awsAuth is here https://code.google.com/p/aws4c/wiki/DevGuide | |
>>> key = get_aws_key('test1') | |
>>> key[0] | |
'test_key_1' | |
>>> key[1] | |
'test_secret_1' | |
>>> key = get_aws_key('test2') | |
>>> key[0] | |
'test_key_2' | |
>>> key[1] | |
'test_secret_2' | |
This function is taken from here https://gist.github.com/vladistan/7666753 | |
""" | |
f = open(os.path.expanduser("~/.awsAuth")) | |
keys = [k for k in [l.strip().split(':') for l in f] if k[0] == key_id][0][1:3] | |
return keys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment