Skip to content

Instantly share code, notes, and snippets.

@thekensta
Created January 19, 2016 12:42
Show Gist options
  • Save thekensta/437797b5622ee746c439 to your computer and use it in GitHub Desktop.
Save thekensta/437797b5622ee746c439 to your computer and use it in GitHub Desktop.
AWS Keys from Credentials
"""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