Skip to content

Instantly share code, notes, and snippets.

@thekensta
Created January 19, 2016 12:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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