Skip to content

Instantly share code, notes, and snippets.

@vladistan
Last active December 29, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladistan/7666753 to your computer and use it in GitHub Desktop.
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
# 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