4

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/"
Community
  • 1
  • 1
orome
  • 45,163
  • 57
  • 202
  • 418

1 Answers1

2

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:

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name:  SOME_PUBLIC_CONFIG
    value: "true"

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.

Nick Humrich
  • 14,905
  • 8
  • 62
  • 85
  • 1
    Also, I assume I should ensure that `.ebextensions/*` is not ignored by Git, right? – orome Jan 12 '15 at 18:41
  • Correct, otherwise it will not get put into your application source. You will need to be able to commit the .ebextensions into git – Nick Humrich Jan 12 '15 at 18:42
  • And thanks for clarifying how optionsettings files are are and were used. That was causing a lot of confusion (esp. since there are lot of out-of-date answers here on SO). I now know where to direct all my AWS-EB questions! – orome Jan 12 '15 at 18:49
  • I have [another, about setting up SSH](http://stackoverflow.com/q/27927555/656912). – orome Jan 13 '15 at 17:06
  • @orome re your first comment, .ebextensions can be ignored by git (it prob should in case you have some sensitive info in any config file) if you use an .ebignore file. see https://forums.aws.amazon.com/message.jspa?messageID=621059#621059 – arturomp Oct 11 '17 at 20:12