Reputation: 336
I installed Django on AWS EC2 and everything is working fine.
When trying to run commands to administrate Django, I receive an error because I'm missing some environment variables.
Environnement details:
For instance, running this from ssh session will fail and say the key doesn't exist:
source /var/app/venv/*/bin/activate
python3
import os
print(os.environ['RDS_DB_NAME'])
How can I get the env variables to be set and usable in SSH?
Note: When Django is run from the server everything works as expected and Django can access the DB, the goal is to be able to manually run commands.
Thank you
Upvotes: 1
Views: 137
Reputation: 238259
You have to manually load those env variables in EB, if you ssh
to your instance:
export $(sudo cat /opt/elasticbeanstalk/deployment/env | xargs)
Upvotes: 1