11
votes

AWS does not properly explain how to manage different deployment environments on the beanstalk with relation to different environments and how to save those settings in your source control repo.

They clearly explain how to setup your python.config in .ebextensions like so:

"aws:elasticbeanstalk:container:python:environment":
  DJANGO_SETTINGS_MODULE: "settings"
  SERVER_ROOT: "/opt/python/current/app/"

However, if you want to have multiple environments like staging and prod you currently have to swap out your configuration files. Whats worse, how do you plan to retain this in your source control tree for shared environments like staging? It appears that every time you push you will need these configuration environment settings.

I've also found that AWS doesnt let me deploy unstaged changes which means writing a script to handle my deployments isnt an option either. What am I missing here?

2

2 Answers

0
votes

Haven't tried it, but it appears that you can pass DJANGO_SETTINGS_MODULE not through configuration file, but through container's own parameters. You can update it through Environment Details -> Edit Configuration -> Container section of Beanstalk console. Just as idea:

  • Create multiple environments "production", "staging", etc
  • Configure each with relevant DJANGO_SETTINGS_MODULE value
  • Remove DJANGO_SETTINGS_MODULE value from .ebextensions
  • Deploy application to pre-created environment
0
votes

I did some digging on this in the past and it seems that they like you to use eb branch to configure the different environments and then configure the option differently within the optionsettings locally on the eb client level (when you init the branch and stuff).

When you think about it, the environment configuration (i.e. DJANGO_SETTINGS_MODULE) should be managed separately from the application code, so I just assume keep it out of the ebextensions and set it up when I navigate to a new environment. If I switch to an existing one need to make sure that value is set properly for the env I want to play in.