Search code examples
node.jsamazon-web-servicesamazon-elastic-beanstalk

How to run eb init specifying node.js version 8?


I run eb init and deploy, I get the node.js version 6, how can I specify that I want node.js version 8 when executing eb init command?


Solution

  • This is an interesting question and I would love to know if there's an easier way, but here's how I got it working:

    1. Determine the latest SolutionStack name as listed here. Presently, this is "64bit Amazon Linux 2017.09 v4.4.4 running Node.js".

    2. Perform eb init -p "64bit Amazon Linux 2017.09 v4.4.4 running Node.js"

    3. create a .ebextensions directory.
    4. create a file .ebextensions/nodejs_version.config
    5. add the following snippet to it:

      option_settings:
        aws:elasticbeanstalk:container:nodejs:
          NodeVersion: 8.9.3
      
    6. eb create
    7. Once the environment has begun building, you can execute:

      aws elasticbeanstalk describe-configuration-settings \
        --environment-name <environment-name> \
        --application-name <application-name>
      

    Look for option settings in the aws:elasticbeanstalk:container:nodejs namespace and you should see the NodeVersion assigned to 8.9.3.

    Ideally, "64bit Amazon Linux 2017.09 v4.4.4 running Node.js" itself should identify the latest version; you shouldn't need to add an option setting for this, unfortunately that is not so.