Reputation: 15030
I am using Amazon Web Services (AWS) Elastic Beanstalk for hosting my Django/Python web application. I have two environments created in Beanstalk - production
and acceptance
(staging).
My web app source code is in version control in git. Deployment config files are located in the .ebextensions
directory at the root of git repository, as described here.
I have 2 separate Django config files for my application: conf/acceptance.py
and conf/production.py
.
How do I set DJANGO_SETTINGS_CONFIG
environment variable separately for each environment?
I have tried editing it in beanstalk web ui, but it is resets when I redeploy. What can I do?
Upvotes: 2
Views: 1576
Reputation: 1118
To set a different value for each environment, you would need to create 2 env config files files for each environment in you .ebextensions folder, then pick ONLY the right one depending on where you deploy. This way your environment property DJANGO_SETTINGS_CONFIG
would automatically be set during deployment and you won't need to change it in the web ui anymore.
Deploy this in acceptance environment:
env-config-acceptance.config
option_settings:
- option_name: DJANGO_SETTINGS_CONFIG
value: config.value.acceptance
Deploy this in production environment:
env-config-production.config
option_settings:
- option_name: DJANGO_SETTINGS_CONFIG
value: config.value.production
Upvotes: 1
Reputation: 177
I have exactly the same setup for one of my own apps. I'm using the Configuration > Software Configuration > Environment Properties section on the Beanstalk UI to set DJANGO_SETTINGS_MODULE
as app.settings.production
or app.settings.staging
depending on the environment. This would likely be app.conf.production
and app.conf.acceptance
for you.
Could it be that one of your .ebxtensions
files has an options_setting
variable that is overriding this during deploy?
Upvotes: 2