Created
January 19, 2016 12:42
-
-
Save thekensta/437797b5622ee746c439 to your computer and use it in GitHub Desktop.
AWS Keys from Credentials
This file contains 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
"""Really simple example of reading aws Key and Secret from credentials file. """ | |
import os | |
from ConfigParser import SafeConfigParser # Python2 | |
def main(profile="default"): | |
config = SafeConfigParser() | |
config.read(os.path.join(os.getenv("HOME"), ".aws/credentials")) | |
secret = config.get(profile, "aws_secret_access_key") | |
key = config.get(profile, "aws_access_key_id") | |
return key, secret | |
if __name__ == "__main__": | |
k, s = main() | |
print(k, s) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment