How are environment variables accessed from ".env" file if Django project deployed to AWS from Github?

I have a Django project deployed on AWS EBS from a Github repo. My secret key is kept on a .env file. I've included the following:

settings.py

from decouple import config
"SECRET_KEY" = config("MY_SECRET_KEY")

requirements.txt

python-decouple==3.7

.env

MY_SECRET_KEY = "THISISMYSECRETKEY-THISISMYSECRETKEY-THISISMYSECRETKEY"

Since I've include .env inside my .gitignore file, the .env is not being pushed to Github. When I try to deploy my project I keep getting an error:

"web: decouple.UndefinedValueError: SECRET_KEY not found". 

The project runs fine on a local server.

With Ashwini's help I was able to figure it out. You can store environment variables in AWS by using the cli:

https://aws.amazon.com/premiumsupport/knowledge-center/elastic-beanstalk-pass-variables/

Additionally, you can view and add environment variables through the AWS dashboard: Elastic Beanstalk / Click on your environment hyperlink / Click "Configuration" (on the left side of the page) / Click the "Edit" button under the software section.

Back to Top