The location and behavior of files used to set AWS Elastic Beanstalk environment properties (e.g. static directory mappings or environment variables) seems to have changed so that much of the information available online appears to be out of date (or at best confusing). In particular, while it is clear that only a single file is currently required for configuration of the environment itself, it is not clear what the relationship between
.elasticbeanstalk/optionsettings.*
and
.ebextensions/*.config
currently is.
Which of these files should be used for setting AWS EB environment properties (e.g. static directory mappings or environment variables), using the current API and (3.x) CLI?
For example, where should a file with contents like this go?
option_settings:
"aws:elasticbeanstalk:application:environment":
SOME_PUBLIC_CONFIG: "true"
SOME_OTHER_THING: "foo"
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "myapp/static/"
You can set any option setting using ebextensions. This will work whether you deploy your code using the api, web console, or CLI.
Create a folder in your project root with the name
.ebextensions
and in that folder, place a file.config
(the dots are important). Then put in your contents:You then need deploy your new application version. Using the CLI you would need to check this into git (if using git), then use
eb deploy
.As far as the differences between this and the .elasticbeanstalk/optionsettings files:
The CLI 3.X no longer uses optionsettings files as they often overrode the settings in the ebextensions. The optionsettings files had a higher precedence then the ebextensions, so if you ever set anything in the optionsettings file, it would no longer work if changed in ebextensions. Ebextensions are a service-wide feature which means they always work no matter what client you are using. Optionsettings files were a CLI specific feature, which made life really confusing for those using multiple clients. As such, 3.x doesnt use optionsettings files.