Question

I am having troubles understanding how .ebextensions is used when deploying a node js application using elasticbeanstalk. I have created a file called 01run.config in the top directory of may application:

my_app:
   |-- server.js
   |-- site/(...)
   |-- node-modules
   |-- .ebextensions/01run.config

The file .ebextensions contains my AWS credentials and a parameter referring to a S3 bundle that my app uses.

option_settings:
  - option_name: AWS_SECRET_KEY
    value:  MY-AWS-SECRET-KEY
  - option_name: AWS_ACCESS_KEY_ID
    value: MY-AWS-KEY-ID
  - option_name: PARAM1
    value: MY-S3-BUNDLE-ID

After deploying my app using eb create, an .elasticbeanstalk/optionsettings.my_app-env is created that contains many variables, amongst which PARAM1 is set to "". Also the credentials do not exist. I think I read somewhere that .ebextensions is when initiating the application, so this is not necessarily bad that I don't see these variables in the optionsettings.my_app-env'. However, the variables are not set up, and the application does not work properly. I'd appreciate any explanations. I find that official documentation a bit confusing to understand.

Was it helpful?

Solution

It seems that the problem was that I had not commited .ebextensions to git. Apparently, the file is read on initializing your application, so it has to be part of the bundle sent to elasticbeanstalk.

I had taken the idea of using the config file to set up the authentication keys from the amazon documentation http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_custom_container.html. However, I had not commited the file because it is clear that you are not supposed to commit your authentication keys (more on this discussion here: How do you pass custom environment variable on Amazon Elastic Beanstalk (AWS EBS)?).

I end up simplifying the file to contain the PARAM1 option, and I passed the secret key and access key id throughout the elasticbenastalk online interface.

OTHER TIPS

Your config file example is missing the namespace. You must specify namespace for each of your option settings.

You can pass the environment options in the .elasticbeanstalk/optionsettings.[your-env-name] file.

You should have a section called [aws:elasticbeanstalk:application:environment]. It might be populated with PARAM1=...etc. Just add your environment variables under this section. The files in the .elasticbeanstalk directory should not be committed.

After doing eb update you can verify that the options were added if you go to the web-based EBS console. The new options should show up. I believe that any old options added through the console do not get removed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top