Skip to content

Commit

Permalink
feat: configure lambda web adapter health check
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreaves committed Sep 20, 2024
1 parent 8461b80 commit 8cb039a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/adapter/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ const app = express();
// Disable X-Powered-By header.
app.disable("x-powered-by");

/**
* Endpoint used by AWS Lambda Web Adapter for readiness checks.
* @see https://github.com/awslabs/aws-lambda-web-adapter#readiness-check
*/
app.get("/__ping", (_req, res) => {
res.status(200).send("Pong");
});

// Register a route which listens to all requests.
app.all("*", async (req, res) => {
/**
Expand Down
3 changes: 2 additions & 1 deletion src/cdk/GatsbySite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ export class GatsbySite extends Construct {
layers: [webAdapterLayer, ...(functionOptions.layers ?? [])],
environment: {
...functionOptions.environment,
// Required by web adapter.
// Configuration for AWS Lambda Web Adapter.
AWS_LAMBDA_EXEC_WRAPPER: "/opt/bootstrap",
AWS_LWA_READINESS_CHECK_PATH: "/__ping",
},
});

Expand Down

0 comments on commit 8cb039a

Please sign in to comment.