cpage
cpage

Reputation: 39

Handling Secret Keys when deploying Flask app on AWS

Working on deploying a Flask application using AWS, but the Flask app relies on API secret keys that I have saved in a config.ini file on my computer. Should I be uploading that file with the keys to AWS? How should my Flask app access those keys once deployed to AWS?

Upvotes: 0

Views: 1837

Answers (2)

Karan Shah
Karan Shah

Reputation: 1324

You can possibly do one of the following (Assuming that you're deploying on a Linux Based OS):

  1. Store the keys in variables and then export them from the file: ~/.bash_profile

  2. Save them as environment variables

    You can checkout this answer to see how to access them : Access environment variables from Python

Upvotes: 1

Manish Joshi
Manish Joshi

Reputation: 3760

I have not used Flask yet but as a good practice for deployment, you should never save your API keys/credentials in plain text anywhere.

For AWS related deployments which require API keys, I would suggest you use the IAM instance roles which have the required access that your application needs.

Upvotes: 2

Related Questions