Configure Node.js Environments on Elastic Beanstalk¶
Prerequisites¶
- A deployed Node.js Elastic Beanstalk environment.
- Project repository initialized with
.elasticbeanstalk/metadata. - Understanding of environment property usage from application code.
- Permission to update environment configuration and deploy new versions.
What You'll Build¶
You will configure runtime values with environment properties, extend environment behavior with .ebextensions, direct process startup with Procfile, run platform hooks, and customize nginx behavior under .platform/nginx.
flowchart TD
A[Environment Properties] --> B[process.env in Node.js app]
C[.ebextensions] --> D[Option settings and resources]
E[Procfile] --> F[Process command]
G[.platform/hooks] --> H[Lifecycle scripts]
I[.platform/nginx] --> J[Reverse proxy customization] Steps¶
-
Add environment properties in Elastic Beanstalk console or CLI and read them in application code.
-
Add
.ebextensionsoption settings for repeatable configuration. -
Define a
Procfilewhen you need explicit process command control. -
Add platform hooks for deployment lifecycle customization.
-
Add nginx custom snippets if you need reverse proxy customization.
-
Redeploy and verify applied settings.
Verification¶
- Application can read configured keys through
process.env. - Environment option settings from
.ebextensionsare visible in effective configuration. Procfilecommand is used as expected for the web process.- Hook scripts execute in lifecycle order without deployment failure.
- nginx custom fragments load successfully and do not break health checks.