David Lance David Lance - 1 year ago 136
Python Question

AWS Elastic Beanstalk Environment Variables in Python

Recently I have been trying to deploy a django webapp to AWS Elastic Beanstalk and everything has been going fine. However part of my app uses that Twitter API so I need to import my API keys. My understanding is that I should use Configuration > Software Configurations > Environment Properties. I set this up inputting my keys but when I checked the site it still failed.

I have been using this to try and import the variables is that correct?

import os


I checked to see if the variables were making it to the server and when I ran
eb printenv
I was shown this:

Environment Variables:

Any help would be greatly appreciated.

Answer Source

The key you are trying to get doesn't exist among your environment variables. Changing the code to - os.environ.get('TWITTER_ACCESS_TOKEN') or any other key among your env vars should do the trick.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download