22
33## Configuration Hierarchy
44
5- Elastic Beanstalk configuration is applied in this order (later overrides earlier
6- for option settings):
5+ Option settings are applied in this order (later overrides earlier):
76
871 . Platform defaults (managed by AWS)
982 . Saved configurations (reusable templates)
1093 . ` .ebextensions/*.config ` files (in source bundle)
11- 4 . Platform hooks (` /platform/hooks/prebuild/ ` , ` predeploy/ ` , ` postdeploy/ ` )
12- 5 . Environment properties (set via console/CLI/API)
10+ 4 . Environment properties (set via console/CLI/API)
1311
14- For option settings, later sources override earlier ones. ` .ebextensions ` and
15- platform hooks also support resource declarations and deploy-time commands that
16- are not expressible as option settings.
12+ Platform hooks (` /platform/hooks/prebuild/ ` , ` predeploy/ ` , ` postdeploy/ ` ) run
13+ shell scripts during deployment lifecycle but do not set option settings.
14+ They are the preferred customization mechanism on AL2023 for non-option-setting
15+ tasks. Use ` .ebextensions/ ` for option settings and resource declarations.
1716
18- Platform hooks are the preferred customization mechanism on AL2023. Use
19- ` .ebextensions/ ` for option settings and resource declarations; use platform
20- hooks for shell scripts that run during deployment lifecycle.
17+ See [ Configuration options precedence] ( https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html#configuration-options-precedence )
18+ for full details.
2119
22- ## ` .ebextensions/ ` Patterns
23-
24- Place YAML ` .config ` files in ` .ebextensions/ ` at the source bundle root.
25- Common patterns:
26-
27- ### Install system packages
28-
29- ``` yaml
30- packages :
31- yum :
32- ImageMagick : []
33- postgresql-devel : []
34- ` ` `
20+ ## Key Patterns
3521
3622### Run commands on deploy
3723
@@ -45,7 +31,7 @@ container_commands:
4531Use ` leader_only: true` for commands that should run on only one instance
4632(database migrations, cache warmup).
4733
48- # # Procfile
34+ # ## Procfile
4935
5036Define the process to run. EB uses this instead of platform defaults :
5137
@@ -59,19 +45,23 @@ HTTP, not a message broker SDK).
5945
6046# # Environment Properties and Secrets
6147
62- Set application configuration as environment variables. Never hardcode secrets
63- in `.ebextensions/` or source code. Reference secrets via Secrets Manager :
48+ Non-secret config uses `aws:elasticbeanstalk:application:environment`. For
49+ secrets, use the native secrets integration which injects Secrets Manager
50+ values as environment variables without application-side SDK calls :
6451
6552` ` ` yaml
6653option_settings:
6754 aws:elasticbeanstalk:application:environment:
68- DB_SECRET_ARN: arn:aws:secretsmanager:us-east-1:123456789:secret:myapp/db
6955 APP_ENV: production
56+ aws:elasticbeanstalk:application:environmentsecrets:
57+ DB_PASSWORD: arn:aws:secretsmanager:us-east-1:123456789:secret:myapp/db
7058` ` `
7159
72- The application reads the secret value at runtime using the Secrets Manager SDK.
73- Provision databases and secrets as separate resources (via CDK, Terraform, or
74- console) — not coupled to the EB environment lifecycle.
60+ Never hardcode secrets in `.ebextensions/` or source code. Provision databases
61+ and secrets as separate resources — not coupled to the EB environment lifecycle.
62+
63+ See [Environment secrets](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuration-envvars.html#configuration-envvars-secrets)
64+ for supported secret sources.
7565
7666# # Deployment Policies
7767
@@ -84,21 +74,29 @@ console) — not coupled to the EB environment lifecycle.
8474
8575Default : All at once for dev, Rolling with additional batch for production.
8676
87- # # Health Check Configuration
77+ See [Deployment policies and settings](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.rolling-version-deploy.html)
78+ for configuration details.
8879
89- ` ` ` yaml
90- option_settings:
91- aws:elasticbeanstalk:environment:process:default:
92- HealthCheckPath: /health
93- HealthCheckInterval: '15'
94- HealthyThresholdCount: '3'
95- UnhealthyThresholdCount: '5'
96- ` ` `
80+ # # Health Check
9781
9882Always configure a dedicated health check endpoint. Do not use `/` if it
9983performs database queries or heavy computation.
10084
101- The agent should verify that the application exposes a health check endpoint
85+ The agent should verify that the application exposes a health endpoint
10286(default : ` /health` ). If no health route exists, scaffold a minimal one that
10387returns 200 OK. The ALB health check will fail without this, causing deployment
10488to roll back.
89+
90+ See [Health check setting](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-alb.html#environments-cfg-alb-health)
91+ for ALB health check configuration.
92+
93+ # # Heroku Migration
94+
95+ When migrating from Heroku/Render/Railway, audit for these patterns :
96+
97+ - ` DATABASE_URL` → Provision RDS/Aurora separately, pass via environment secrets
98+ - ` REDIS_URL` → Provision ElastiCache, pass endpoint via environment properties
99+ - Add-on env vars (e.g., `SENDGRID_API_KEY`) → Store in Secrets Manager
100+ - ` PORT` → EB sets this automatically, no change needed
101+ - ` Procfile` → Works as-is (same format)
102+ - Explicit AWS credentials → Remove; use IAM instance profile instead
0 commit comments