Recipe: Custom Platform Hooks and nginx Extensions¶
Prerequisites¶
- Elastic Beanstalk Node.js environment on Linux platform.
- Repository access to add
.platformdirectory content. - Shell scripting familiarity for lifecycle hook scripts.
- Awareness of deployment sequence and rollback behavior.
What You'll Build¶
You will extend platform behavior by adding lifecycle hook scripts under .platform/hooks and reverse proxy fragments under .platform/nginx, enabling custom validation, migration, and response handling logic.
flowchart TD
A[Application Source Bundle] --> B[.platform/hooks/prebuild]
B --> C[.platform/hooks/predeploy]
C --> D[Deploy Application]
D --> E[.platform/hooks/postdeploy]
A --> F[.platform/nginx/conf.d/*.conf]
F --> G[nginx runtime behavior] Steps¶
-
Create lifecycle hook script files with executable permissions.
-
Keep scripts idempotent and fail-fast on unrecoverable conditions.
-
Add nginx custom configuration snippets in
.platform/nginx/conf.d/. -
Deploy and inspect deployment logs for hook execution order.
-
Validate nginx behavior by issuing HTTP requests.
-
Keep hook scripts compatible with Linux shell execution in Elastic Beanstalk instances.
- Add explicit shebang lines.
- Use executable file permissions.
- Avoid assumptions about interactive shell input.
-
Document the operational purpose of each hook.
- Validation.
- Migration.
- Post-deploy smoke checks.
Verification¶
- Hook scripts run at expected lifecycle stages.
- Deployment fails early when preconditions are not met.
- nginx snippets are loaded without syntax errors.
- Response headers or routing behaviors reflect custom config.
- Hook intent and failure modes are documented for operators.