Add config files to your elastic beanstalk project to seed environment information. Use module to get environment info in your app.
To get command line tool:
npm install eb-env -g
To add to your project:
npm install eb-env
From project root:
The above command will add a config file to your .ebextensions directory. The config file will add environment information to a temp file so the eb-env module can consume it.
var ebEnv = require('eb-env'); var envName = ebEnv.name;
By default, the environment info is loaded from the temp file mentioned above and copied into a file in the module directory (in case the temp file goes away). Alternatively, you can load from a different file:
var ebEnv = require('eb-env'); ebEnv.load('/my/eb-env.json'); var envName = ebEnv.name;
Available environment info
The full name of your elastic beanstalk environment.
The URL where the source of your app was retrieved.
The commit ID of the deployed version of your app.