Releases: aws-powertools/powertools-lambda-typescript
v2.33.0
Summary
In this release, the HTTP event handler gains a new metrics middleware that lets you emit per-request latency, fault, and error metrics with a single line of configuration. The middleware automatically uses the matched route as a dimension and attaches request metadata like HTTP method, path, status code, and API Gateway request IDs.
We've also improved the parser package by exporting InferOutput from the public types entry point, resolving a TypeScript declaration emit error (TS2883) that affected consumers using safeParse mode — particularly those upgrading to TypeScript 6.
⭐ Congratulations to @yashar-new10 and @faberchri for their first PR merged in the project 🎉
Metrics Middleware
You can now use the Metrics utility with the HTTP event handler to automatically emit CloudWatch metrics for every request. The middleware:
- Adds the matched route as a metric dimension (e.g.,
GET /users/:id) - Emits
latency(Milliseconds),fault(Count), anderror(Count) metrics - Attaches request metadata including
httpMethod,path,statusCode,userAgent, andipAddress - Adds API Gateway-specific metadata (
apiGwRequestId,apiGwApiId) when available - Uses
NOT_FOUNDas the route dimension when no route matches, preventing dimension explosion
import { Router } from '@aws-lambda-powertools/event-handler/http';
import { metrics as metricsMiddleware } from '@aws-lambda-powertools/event-handler/http/middleware/metrics';
import { Metrics } from '@aws-lambda-powertools/metrics;
import type { Context } from 'aws-lambda';
const metrics = new Metrics({ namespace: 'my-app', serviceName: 'my-service' });
const app = new Router();
app.use(metricsMiddleware(metrics));
app.get('/users/:id', async ({ params }) => {
return { id: params.id, name: 'Jane' };
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);Changes
- improv(parser): export InferOutput from public types entry point (#5175) by @yashar-new10
- chore(deps): add esbuild as explicit devDependency (#5173) by @sdangol
- chore: temporarily remove Bahrain (me-south-1) region from layer publishing (#5169) by @svozza
- docs(commons): fix isStrictEqual and areArraysEqual JSDoc array comparison description (#5165) by @Zelys-DFKH
- docs: fix dependencies & broken references (#5156) by @dreamorosi
- docs: fix markdown table format (#5153) by @dothomson
- style: remove useAwait linting rule (#5146) by @dreamorosi
- docs(event-handler): update custom middleware example to use Store API (#5145) by @svozza
- fix(commons): don't overwrite existing value with
undefinedin deepMerge (#5141) by @faberchri - fix(event-handler): http response body validation typings (#5125) by @nateiler
- feat(event-handler): add metrics middleware for HTTP routes (#5086) by @svozza
- fix: update middy types to be aligned with 7.1.2 update (#5100) by @willfarrell
- fix(commons): rename AvailabilityZoneId to AvailabilityZoneID in docs and tests (#5118) by @svozza
🔧 Maintenance
- chore(deps): bump actions/upload-artifact from 7.0.0 to 7.0.1 (#5181) by @dependabot[bot]
- chore(deps-dev): bump typedoc from 0.28.18 to 0.28.19 in the typescript group across 1 directory (#5182) by @dependabot[bot]
- chore(deps): bump actions/github-script from 8.0.0 to 9.0.0 (#5177) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 7.1.1 to 7.2.0 (#5178) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.4.10 to 2.4.11 (#5179) by @dependabot[bot]
- chore(deps): bump @types/node from 25.5.2 to 25.6.0 (#5180) by @dependabot[bot]
- chore(deps): bump aws-actions/configure-aws-credentials from 6.0.0 to 6.1.0 (#5170) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#5176) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#5171) by @dependabot[bot]
- chore(deps-dev): bump protobufjs from 8.0.0 to 8.0.1 (#5164) by @dependabot[bot]
- chore(deps-dev): bump typedoc-plugin-missing-exports from 4.1.2 to 4.1.3 in the typescript group across 1 directory (#5163) by @dependabot[bot]
- chore(deps): bump @types/node from 25.5.0 to 25.5.2 (#5161) by @dependabot[bot]
- chore(deps): bump esbuild from 0.27.5 to 0.28.0 (#5160) by @dependabot[bot]
- chore(deps): bump esbuild from 0.27.4 to 0.27.5 (#5159) by @dependabot[bot]
- chore(deps-dev): bump @valkey/valkey-glide from 2.3.0 to 2.3.1 (#5158) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.4.9 to 2.4.10 (#5152) by @dependabot[bot]
- chore(deps): bump pygments from 2.18.0 to 2.20.0 in /docs (#5150) by @dependabot[bot]
- chore(deps): bump zgosalvez/github-actions-ensure-sha-pinned-actions from 5.0.3 to 5.0.4 (#5149) by @dependabot[bot]
- chore(deps): bump actions/setup-go from 6.3.0 to 6.4.0 (#5148) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.35.0 to 4.35.1 (#5147) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#5140) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.34.1 to 4.35.0 (#5139) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.4.8 to 2.4.9 (#5136) by @dependabot[bot]
- chore(deps): bump the typescript group across 1 directory with 2 updates (#5134) by @dependabot[bot]
- chore(deps): bump requests from 2.32.4 to 2.33.0 in /docs (#5137) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#5132) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#5135) by @dependabot[bot]
- chore(deps-dev): bump @valkey/valkey-glide from 2.2.7 to 2.3.0 (#5123) by @dependabot[bot]
- chore(deps): bump constructs from 10.5.1 to 10.6.0 (#5129) by @dependabot[bot]
- chore(deps-dev): bump markdownlint-cli2 from 0.21.0 to 0.22.0 (#5130) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.34.0 to 4.34.1 (#5127) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.7.5 to 9.7.6 in /docs (#5122) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 61 updates (#5131) by @dependabot[bot]
- chore(deps): bump zgosalvez/github-actions-ensure-sha-pinned-actions from 5.0.2 to 5.0.3 (#5121) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.33.0 to 4.34.0 (#5120) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
c373999to868ad4din /docs (#5119) by @dependabot[bot] - chore(deps-dev): bump @biomejs/biome from 2.4.7 to 2.4.8 (#5115) by @dependabot[bot]
- chore(deps): bump valibot from 1.3.0 to 1.3.1 (#5116) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 7.1.0 to 7.1.1 (#5114) by @dependabot[bot]
This release was made possible by the following contributors:
@Zelys-DFKH, @dependabot[bot], @dothomson, @dreamorosi, @faberchri, @github-actions[bot], @nateiler, @sdangol, @svozza, @willfarrell, @yashar-new10, dependabot[bot] and github-actions[bot]
v2.32.0
Summary
In this release, we are pleased to announce a new utility for interacting with the Lambda Metadata Service in the commons package, allowing you to easily retrieve information about the Lambda function, such as the Availability Zone ID.
In the HTTP event handler, we have delivered two much requested features: a type-safe Store API, letting you share state between middleware and route handlers with full type safety, and request and response validation, so you can enforce data contracts at your API boundary, eliminating manual parsing and type assertion code.
We've also fixed a bug where the Kafka consumer would throw when processing tombstone events with undefined values.
⭐ Congratulations to @haslers for their first PR merged in the project 🎉
Lambda Metadata Service
A new getMetadata() utility in the commons package fetches metadata from the AWS Lambda Metadata endpoint. The utility automatically returns an empty object outside of Lambda, so your code works seamlessly in local development and testing.
import { getMetadata } from '@aws-lambda-powertools/commons/utils/metadata';
import { Logger } from '@aws-lambda-powertools/logger';
const logger = new Logger({ serviceName: 'serverlessAirline' });
const metadata = await getMetadata();
export const handler = async () => {
const { AvailabilityZoneID: azId } = metadata;
logger.appendKeys({ azId });
};Type-safe Store API
The HTTP event handler now includes a Store API that provides type-safe, scoped state management for route handlers with two built-in storage scopes:
- Request store — per-invocation state (set in middleware, read in handlers). Cleared automatically between requests.
- Shared store — router-scoped state (set at cold start, read everywhere). Persists across invocations.
import { Router } from '@aws-lambda-powertools/event-handler/http';
import type { Context } from 'aws-lambda';
type AppEnv = {
store: {
request: { userId: string; isAdmin: boolean };
shared: { db: { query: (sql: string) => Promise<unknown> } };
};
};
const app = new Router<AppEnv>();
app.shared.set('db', createDbClient());
app.use(async ({ reqCtx, next }) => {
const auth = reqCtx.req.headers.get('Authorization') ?? '';
const { sub, isAdmin } = jwt.verify(auth.replace('Bearer ', ''), 'secret');
reqCtx.set('userId', sub);
reqCtx.set('isAdmin', isAdmin);
await next();
});
app.get('/profile', async (reqCtx) => {
const userId = reqCtx.get('userId'); // typed as string
const db = reqCtx.shared.get('db'); // typed as { query: ... }
if (!userId || !db) return { error: 'not ready' };
return { userId };
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);Validation Middleware
The new validation feature validates validates request and response data against Standard Schema v1 schemas — a vendor-neutral interface supported by Zod, Valibot, ArkType, and other popular libraries.
You can validate any combination of request body, headers, path parameters, and query parameters. Request validation errors return a structured 422 Unprocessable Entity response, and response validation errors return 500 Internal Server Error. TypeScript infers the handler's context type from your schema config — only validated fields are accessible, catching mismatches at compile time.
import { Router } from '@aws-lambda-powertools/event-handler/http';
import type { Context } from 'aws-lambda';
import { z } from 'zod';
const app = new Router();
const createTodoSchema = z.object({ title: z.string() });
const todoResponseSchema = z.object({
id: z.string(),
title: z.string(),
completed: z.boolean(),
});
app.post(
'/todos',
(reqCtx) => {
const { title } = reqCtx.valid.req.body; // fully typed
return { id: '123', title, completed: false };
},
{
validation: {
req: { body: createTodoSchema },
res: { body: todoResponseSchema }, // runtime check on the response
},
}
);
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);Changes
- fix(commons): rename AvailabilityZoneId to AvailabilityZoneID in docs and tests (#5118) by @svozza
- chore(ci): temporarily disable me-central-1 deployments (#5111) by @svozza
- feat(commons): add Lambda Metadata Service support (#5109) by @svozza
- revert: feat(commons): add Lambda Metadata Service support (#5106) (#5107) by @svozza
- feat(commons): add Lambda Metadata Service support (#5106) by @svozza
- feat(event-handler): add type-safe Store API for request and shared state (#5081) by @svozza
- chore(deps): regenerate package-lock.json to clear stale Dependabot alerts (#5075) by @dreamorosi
- fix(event-handler): add overloads to route() for typed validation context (#5052) by @svozza
- chore: run linting on packages, run npm audit fix manually, address SonarCloud (#5046) by @dreamorosi
- fix(event-handler): default error handler returns a web Response correctly (#5024) by @nateiler
- fix(kafka): handle tombstone events without value (#5017) by @haslers
- ci: use ts extension in layer CDK stack imports (#5010) by @svozza
- ci: fix layer import in CDK stack (#5009) by @dreamorosi
📜 Documentation updates
🔧 Maintenance
- chore(deps-dev): bump @biomejs/biome from 2.4.7 to 2.4.8 (#5115) by @dependabot[bot]
- chore(deps): bump valibot from 1.3.0 to 1.3.1 (#5116) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 7.1.0 to 7.1.1 (#5114) by @dependabot[bot]
- chore(deps): bump valibot from 1.2.0 to 1.3.0 (#5101) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.4.6 to 2.4.7 (#5097) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 7.0.0 to 7.1.0 (#5104) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 6.4.0 to 7.0.0 (#5095) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#5099) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 102 updates (#5098) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 16.3.3 to 16.4.0 (#5096) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.32.6 to 4.33.0 (#5094) by @dependabot[bot]
- chore(deps): bump zgosalvez/github-actions-ensure-sha-pinned-actions from 5.0.1 to 5.0.2 (#5093) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#5088) by @dependabot[bot]
- chore(deps): bump @types/node from 25.4.0 to 25.5.0 (#5091) by @dependabot[bot]
- chore(deps): bump @aws/lambda-invoke-store from 0.2.3 to 0.2.4 (#5089) by @dependabot[bot]
- chore(deps): bump esbuild from 0.27.3 to 0.27.4 (#5090) by @dependabot[bot]
- chore(deps): bump actions/download-artifact from 8.0.0 to 8.0.1 (#5087) by @dependabot[bot]
- chore(deps-dev): bump @aws/durable-execution-sdk-js from 1.0.2 to 1.1.0 (#5085) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.7.4 to 9.7.5 in /docs (#5084) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
f4332a8toc373999in /docs (#5083) by @dependabot[bot] - chore(deps-dev): bump lint-staged from 16.3.2 to 16.3.3 (#5080) by @dependabot[bot]
- chore(deps): bump @types/node from 25.3.5 to 25.4.0 (#5079) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#5078) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 6.3.0 to 6.4.0 (#5076) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 115 updates (#5077) by @dependabot[bot]
- chore(deps): bump @types/node from 25.3.3 to 25.3.5 (#5071) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.4.5 to 2.4.6 (#5070) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 6.2.0 to 6.3.0 (#5069) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.32.5 to 4.32.6 (#5068) by @dependabot[bot]
- chore(deps): bump markdown from 3.7 to 3.8.1 in /docs (#5067) by @dependabot[bot]
- chore(deps): bump arktype from 2.1.29 to 2.2.0 (#5066) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 16.3.1 to 16.3.2 (#5065) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.7.3 to 9.7.4 in /docs (#5064) by @dependabot[bot]
- chore(deps): bump actions/setup-node from 6.2...
v2.31.0
Summary
In this release we are pleased to announce Tracer middleware for the HTTP event handler, which allows users to enable distributed tracing for their HTTP routes with minimal boilerplate code.
In addition, the metric utility now supports a fluent interface, allowing you to chain multiple methods in a single statement.
We have also fixed a bug in the HTTP event handler that caused parameterized headers to be handled incorrectly.
⭐ Special thanks to @nateiler and @dothomson for their first PR merged in the project, and to @arnabrahman! for another great contribution 🎉
Tracer Middleware
You can now use the Tracer utility with the HTTP event handler to gain observability over your routes. The middleware:
- Creates a subsegment for each HTTP route with the format
METHOD /path(e.g.,GET /users) - Adds
ColdStartandServiceannotations - Optionally captures JSON response bodies as metadata
- Captures errors as metadata when exceptions occur
import { Router } from '@aws-lambda-powertools/event-handler/http';
import { tracer as tracerMiddleware } from '@aws-lambda-powertools/event-handler/http/middleware/tracer';
import { Tracer } from '@aws-lambda-powertools/tracer';
import type { Context } from 'aws-lambda';
const tracer = new Tracer({ serviceName: 'my-api' });
const app = new Router();
app.get(
'/users/cards',
[tracerMiddleware(tracer, { captureResponse: false })],
({ params }) => {
return { id: params.id, secret: 'sensitive-data' };
}
);
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);Metrics Fluent Interface
All mutation methods (with the exception of clear*) now return the metric instance that was mutated, allowing you to chain multiple metrics operations in a single statement.
import { Metrics} from '@aws-lambda-powertools/metrics';
const metrics = new Metrics();
metrics
.addDimension('environment', 'prod')
.addDimension('commit', '1234')
.addMetric('test1', MetricUnit.Count, 1);
.addMetric('test2', MetricUnit.Count, 1);Changes
- ci: use ts extension in layer CDK stack imports (#5010) by @svozza
- ci: fix layer import in CDK stack (#5009) by @dreamorosi
- fix(event-handler): handle set-cookie header values with multiple attributes (#4990) by @nateiler
- chore: manually upgrade dependency tree (#5002) by @dreamorosi
- ci: switch npm auth to OIDC (#4997) by @dreamorosi
- fix(kafka): handle tombstone events (#4991) by @dreamorosi
- test: extract DF idempotency e2e tests (#4994) by @dreamorosi
- ci: remove workflow-based PR automation (#4996) by @dreamorosi
- chore(ci): update layer script to include event-handler (#4956) by @svozza
- feat(metrics): return metrics instance from metrics functions (#4930) by @dothomson
- feat(parameters): pass underlying SDK error as cause to
GetParameterError(#4936) by @felsidian
📜 Documentation updates
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4985) by @dependabot[bot]
- feat(event-handler): add tracer middleware for HTTP routes (#4982) by @arnabrahman
- chore(deps): bump @types/node from 25.1.0 to 25.2.0 (#4983) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 49 updates (#4984) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.10 to 25.1.0 (#4980) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 43 updates (#4975) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4976) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4959) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.9 to 25.0.10 (#4968) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 93 updates (#4958) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.159 to 8.10.160 (#4963) by @dependabot[bot]
- chore(deps): bump constructs from 10.4.4 to 10.4.5 (#4957) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.8 to 25.0.9 (#4954) by @dependabot[bot]
- docs(event-handler): add http router decorator examples (#4950) by @matthew2564
- chore(deps): bump @types/node from 25.0.6 to 25.0.8 (#4952) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4947) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.3 to 25.0.6 (#4945) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 62 updates (#4946) by @dependabot[bot]
- improv(docs): fixed the extra dependencies table (#4940) by @sdangol
🔧 Maintenance
- chore(deps-dev): bump @valkey/valkey-glide from 2.2.6 to 2.2.7 (#5006) by @dependabot[bot]
- chore(deps): bump @types/node from 25.2.0 to 25.2.2 (#5004) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.32.1 to 4.32.2 (#4998) by @dependabot[bot]
- chore(deps): bump @types/node from 25.2.0 to 25.2.1 (#4999) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4985) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.32.0 to 4.32.1 (#4987) by @dependabot[bot]
- chore(deps): bump aws-actions/configure-aws-credentials from 5.1.1 to 6.0.0 (#4992) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.3.13 to 2.3.14 (#4989) by @dependabot[bot]
- feat(event-handler): add tracer middleware for HTTP routes (#4982) by @arnabrahman
- chore(deps): bump @types/node from 25.1.0 to 25.2.0 (#4983) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 49 updates (#4984) by @dependabot[bot]
- test: add e2e tests for batch processing (#4978) by @dreamorosi
- test(idempotency): add Durable function e2e test case (#4979) by @dreamorosi
- chore(deps): bump @types/node from 25.0.10 to 25.1.0 (#4980) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.3.11 to 2.3.13 (#4974) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 43 updates (#4975) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.31.10 to 4.32.0 (#4977) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4976) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#4970) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4959) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.9 to 25.0.10 (#4968) by @dependabot[bot]
- chore(deps): bump actions/setup-python from 6.1.0 to 6.2.0 (#4967) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 6.1.1 to 6.2.0 (#4966) by @dependabot[bot]
- chore(deps): bump actions/checkout from 6.0.1 to 6.0.2 (#4969) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 93 updates (#4958) by @dependabot[bot]
- chore(deps-dev): bump zod from 4.3.5 to 4.3.6 (#4971) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.159 to 8.10.160 (#4963) by @dependabot[bot]
- chore(deps-dev): bump @valkey/valkey-glide from 2.2.5 to 2.2.6 (#4962) by @dependabot[bot]
- chore(deps): bump release-drafter/release-drafter from 6.1.0 to 6.1.1 (#4961) by @dependabot[bot]
- chore(deps): bump constructs from 10.4.4 to 10.4.5 (#4957) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.8 to 25.0.9 (#4954) by @dependabot[bot]
- chore(deps): bump actions/setup-node from 6.1.0 to 6.2.0 (#4953) by @dependabot[bot]
- chore(deps): bump actions/setup-go from 6.1.0 to 6.2.0 (#4948) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.6 to 25.0.8 (#4952) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4947) by @dependabot[bot]
- chore(deps-dev): bump @valkey/valkey-glide from 2.2.1 to 2.2.5 (#4944) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updat...
v2.30.2
Summary
In this release we have added Middy v7 middleware compatibility which enables developers using Middy to use Durable functions, Tenant isolation mode, and multi-concurrency on Lambda Managed Instances.
We have also now added a new tenantId property by default for tenant identification in all log entries, making it easier to filter and trace logs across different tenants in your Lambda functions.
⭐ Special thanks to @coderbyheart for their first PR merged in the project 🎉
Changes
- feat: allow @middy/core v7 (#4918) by @coderbyheart
- feat(logger): add tenantId to logger default properties (#4931) by @kawaaaas
- improv(ci): Added environment suffix to prevent artefact name conflict (#4921) by @sdangol
📜 Documentation updates
- chore(deps): bump urllib3 from 2.6.0 to 2.6.3 in /docs (#4927) by @dependabot[bot]
- improv(docs): added a note for customers migrating from
BatchProcessorSynctoBatchProcessor(#4926) by @sdangol - improv(docs): updated the Maintainer's Playbook with the updated CI process (#4922) by @sdangol
🔧 Maintenance
- chore(batch): remove invoke store global namespace workaround (#4932) by @svozza
- chore(deps): bump urllib3 from 2.6.0 to 2.6.3 in /docs (#4927) by @dependabot[bot]
- feat: remove baseUrl from TypeScript configurations for future compiler compatibility (#4925) by @dreamorosi
- improv(docs): updated the Maintainer's Playbook with the updated CI process (#4922) by @sdangol
This release was made possible by the following contributors:
@coderbyheart, @dependabot[bot], @dreamorosi, @github-actions[bot], @kawaaaas, @sdangol, @svozza, dependabot[bot] and github-actions[bot]
v2.30.1
Summary
In this release we have removed lodash.merge , allowing users to simplify their bundling process as special handling of this CommonJS only dependency is no longer required.
⭐ Special thanks to @jaimellamasi for their work on the lodash migration! 🎉
Changes
- improv(ci): Added environment suffix to prevent artefact name conflict (#4921) by @sdangol
- fix(logger): improve e2e test resilience by grouping logs by level (#4909) by @dreamorosi
- chore(ci): prevent parameter injection in make-version workflow (#4900) by @dreamorosi
- chore(ci): harden workflow permissions for security compliance (#4898) by @dreamorosi
- improv(ci): fixed the Make Release workflow (#4867) by @sdangol
- improv(ci): automated the Gamma/Prod deployment to China/GovCloud regions (#4864) by @sdangol
📜 Documentation updates
- improv(docs): updated the Maintainer's Playbook with the updated CI process (#4922) by @sdangol
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 27 updates (#4912) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4913) by @dependabot[bot]
- chore(maintenance): general refactoring (#4905) by @dreamorosi
- chore(maintenance): remove cloud dev environment configurations (#4896) by @dreamorosi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 92 updates (#4893) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4894) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
980e11fto3bba0a9in /docs (#4888) by @dependabot[bot] - chore(deps): bump @types/node from 25.0.2 to 25.0.3 (#4885) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.7.0 to 9.7.1 in /docs (#4889) by @dependabot[bot]
- chore(deps): bump esbuild from 0.27.1 to 0.27.2 (#4884) by @dependabot[bot]
- chore(deps): bump pymdown-extensions from 10.10.2 to 10.16.1 in /docs (#4881) by @dependabot[bot]
- docs: add EF Education First as customer reference (#4877) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4875) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.1 to 25.0.2 (#4872) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 30 updates (#4874) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.0 to 25.0.1 (#4866) by @dependabot[bot]
- chore(deps): bump @types/node from 24.10.2 to 25.0.0 (#4863) by @dependabot[bot]
- chore(deps): bump constructs from 10.4.3 to 10.4.4 (#4862) by @dependabot[bot]
- chore(ci): bumped the layer verison from 41 to 42 (#4861) by @sdangol
🔧 Maintenance
- improv(docs): updated the Maintainer's Playbook with the updated CI process (#4922) by @sdangol
- refactor(logger): replace lodash.merge with internal deepMerge utility (#4892) by @jaimellamasi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 27 updates (#4912) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4913) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.3.10 to 2.3.11 (#4911) by @dependabot[bot]
- chore(deps-dev): bump zod from 4.3.4 to 4.3.5 (#4910) by @dependabot[bot]
- chore(deps-dev): bump zod from 4.2.1 to 4.3.4 (#4903) by @dependabot[bot]
- chore(maintenance): remove cloud dev environment configurations (#4896) by @dreamorosi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 92 updates (#4893) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4894) by @dependabot[bot]
- chore(deps-dev): bump protobufjs from 7.5.4 to 8.0.0 (#4886) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
980e11fto3bba0a9in /docs (#4888) by @dependabot[bot] - chore(deps-dev): bump @biomejs/biome from 2.3.9 to 2.3.10 (#4890) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.31.8 to 4.31.9 (#4882) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.2 to 25.0.3 (#4885) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.7.0 to 9.7.1 in /docs (#4889) by @dependabot[bot]
- chore(deps): bump esbuild from 0.27.1 to 0.27.2 (#4884) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#4883) by @dependabot[bot]
- chore(deps): bump pymdown-extensions from 10.10.2 to 10.16.1 in /docs (#4881) by @dependabot[bot]
- chore(deps): bump @standard-schema/spec from 1.0.0 to 1.1.0 (#4880) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.3.8 to 2.3.9 (#4879) by @dependabot[bot]
- chore(deps-dev): bump zod from 4.2.0 to 4.2.1 (#4878) by @dependabot[bot]
- docs: add EF Education First as customer reference (#4877) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4875) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.1 to 25.0.2 (#4872) by @dependabot[bot]
- chore(deps): bump arktype from 2.1.28 to 2.1.29 (#4871) by @dependabot[bot]
- chore(deps): bump zgosalvez/github-actions-ensure-sha-pinned-actions from 4.0.0 to 4.0.1 (#4870) by @dependabot[bot]
- chore(deps): bump actions/download-artifact from 6.0.0 to 7.0.0 (#4869) by @dependabot[bot]
- chore(deps): bump actions/upload-artifact from 5.0.0 to 6.0.0 (#4868) by @dependabot[bot]
- chore(deps-dev): bump zod from 4.1.13 to 4.2.0 (#4873) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 30 updates (#4874) by @dependabot[bot]
- chore(deps): bump @types/node from 25.0.0 to 25.0.1 (#4866) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.31.7 to 4.31.8 (#4865) by @dependabot[bot]
- chore(deps): bump @types/node from 24.10.2 to 25.0.0 (#4863) by @dependabot[bot]
- chore(deps): bump constructs from 10.4.3 to 10.4.4 (#4862) by @dependabot[bot]
This release was made possible by the following contributors:
@dependabot[bot], @dreamorosi, @github-actions[bot], @jaimellamasi, @sdangol, dependabot[bot] and github-actions[bot]
v2.30.0
Summary
We're excited to announce AWS Lambda durable function support in Powertools for AWS Lambda TypeScript. This allows you to leverage AWS Lambda's new durable execution capabilities while taking the advantage of features such as maintaining idempotency guarantees, making it easier to build reliable serverless workflows that span multiple invocations.
AWS Lambda durable functions allow you to simplify building multi-step applications and AI workflows. These functions automatically checkpoint progress, suspend execution for up to one year during long-running tasks, and recover from failures without the need to manage additional infrastructure.
Note
Lambda function handlers using MiddyJS or Class method decorators aren’t compatible with Durable Function handlers at this time.
Tracking issues: MiddyJS middyjs/middy#1531
Class Decorator #4832
This release also includes some bug fixes and a documentation improvement with the help of the community.
⭐ Congratulations to @jinxiao and @dwandro for their first PR merged in the project 🎉
Changes
- fix(logger): merged temp keys with same keys when appending to the logger (#4840) by @sdangol
- fix(idempotency): Update durableExecutionMode string (#4837) by @ConnorKirk
- feat(idempotency): Allow durable function to replay (#4834) by @ConnorKirk
- fix(event-handler): threshold limit for compression not respected when content-length not set (#4827) by @svozza
- feat(parser): fix DynamoDBStreamChangeRecordSchema.dynamodb type (#4817) by @benthorner
📜 Documentation updates
- chore(ci): bumped the layer verison from 41 to 42 (#4861) by @sdangol
- chore(deps-dev): bump markdownlint-cli2 from 0.19.1 to 0.20.0 (#4853) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.228.0 to 2.232.1 in the aws-cdk group across 1 directory (#4855) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 42 updates (#4854) by @dependabot[bot]
- chore(deps): bump @types/node from 24.10.1 to 24.10.2 (#4856) by @dependabot[bot]
- chore(deps): bump urllib3 from 2.5.0 to 2.6.0 in /docs (#4850) by @dependabot[bot]
- chore(deps): bump esbuild from 0.27.0 to 0.27.1 (#4849) by @dependabot[bot]
- chore(deps): bump tsx from 4.20.6 to 4.21.0 (#4829) by @dependabot[bot]
- docs(parser): fixed a typo for the SqsEnvelope built-in envelope (#4826) by @sdangol
- fix: fix China region arn typo (#4820) by @jinxiao
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 56 updates (#4811) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4812) by @dependabot[bot]
- chore(ci): bumped the layer verison from 40 to 41 (#4800) by @sdangol
🔧 Maintenance
- chore(deps-dev): bump aws-sdk from 2.1692.0 to 2.1693.0 (#4857) by @dependabot[bot]
- chore(deps-dev): bump markdownlint-cli2 from 0.19.1 to 0.20.0 (#4853) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.228.0 to 2.232.1 in the aws-cdk group across 1 directory (#4855) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 42 updates (#4854) by @dependabot[bot]
- chore(deps): bump @types/node from 24.10.1 to 24.10.2 (#4856) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.31.6 to 4.31.7 (#4852) by @dependabot[bot]
- chore(deps): bump urllib3 from 2.5.0 to 2.6.0 in /docs (#4850) by @dependabot[bot]
- chore(deps): bump @aws/lambda-invoke-store from 0.2.1 to 0.2.2 (#4847) by @dependabot[bot]
- chore(deps): bump esbuild from 0.27.0 to 0.27.1 (#4849) by @dependabot[bot]
- chore(deps-dev): bump @valkey/valkey-glide from 2.2.0 to 2.2.1 (#4848) by @dependabot[bot]
- chore(deps): bump arktype from 2.1.27 to 2.1.28 (#4845) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#4844) by @dependabot[bot]
- chore(deps): bump actions/stale from 10.1.0 to 10.1.1 (#4843) by @dependabot[bot]
- chore(deps): bump actions/setup-node from 6.0.0 to 6.1.0 (#4842) by @dependabot[bot]
- chore(deps): bump actions/checkout from 6.0.0 to 6.0.1 (#4841) by @dependabot[bot]
- chore(deps): update package lock file for invoke store (#4836) by @svozza
- fix(deps): revert @aws/lambda-invoke-store to dependency (#4833) by @dwandro
- chore(deps): bump github/codeql-action from 4.31.5 to 4.31.6 (#4830) by @dependabot[bot]
- chore(deps): bump tsx from 4.20.6 to 4.21.0 (#4829) by @dependabot[bot]
- chore(deps-dev): bump typedoc from 0.28.14 to 0.28.15 in the typescript group across 1 directory (#4828) by @dependabot[bot]
- chore(deps-dev): bump @valkey/valkey-glide from 2.1.2 to 2.2.0 (#4825) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.3.7 to 2.3.8 (#4824) by @dependabot[bot]
- chore(deps): bump vscode/devcontainers/javascript-node from
fd373e0to88852e0in /.devcontainer (#4823) by @dependabot[bot] - chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#4818) by @dependabot[bot]
- chore(deps): bump aws-actions/configure-aws-credentials from 5.1.0 to 5.1.1 (#4814) by @dependabot[bot]
- chore(deps): bump actions/setup-python from 6.0.0 to 6.1.0 (#4815) by @dependabot[bot]
- chore(deps): bump valibot from 1.1.0 to 1.2.0 (#4816) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 56 updates (#4811) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4812) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.31.4 to 4.31.5 (#4813) by @dependabot[bot]
- chore(deps-dev): bump markdownlint-cli2 from 0.19.0 to 0.19.1 (#4810) by @dependabot[bot]
- chore(deps-dev): bump zod from 4.1.12 to 4.1.13 (#4809) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#4808) by @dependabot[bot]
- chore(event-handler): export types for event handler middleware (#4807) by @svozza
- chore(deps-dev): bump @biomejs/biome from 2.3.5 to 2.3.7 (#4791) by @dependabot[bot]
This release was made possible by the following contributors:
@ConnorKirk, @benthorner, @dependabot[bot], @dwandro, @github-actions[bot], @jinxiao, @sdangol, @svozza, dependabot[bot] and github-actions[bot]
v2.29.0
Summary
🎉 Powertools for AWS Lambda (Typescript) - Event Handler Utility is now Generally Available (GA)
We're excited to announce that the Event Handler utility is now production-ready! 🚀
Event Handler provides lightweight routing to reduce boilerplate for API Gateway REST/HTTP API, ALB and Lambda Function URLs.
⭐ Congratulations to @yoshi-taka, @iamgerg, @fidelisojeah, and @benthorner for their first PR merged in the project 🎉
Import path update
With Event Handler moving to GA, the import path has changed from the experimental namespace to a stable one.
// Before
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
// Now
import { Router } from '@aws-lambda-powertools/event-handler/http';Support for HTTP APIs, ALB, and Function URL
Event Handler now supports HTTP APIs (API Gateway v2), Application Load Balancers (ALB) and Lambda Function URL in addition to the existing REST API and support. This means you can use the same routing API across different AWS services, making it easier to build and migrate serverless applications regardless of your chosen architecture.
import { Router } from '@aws-lambda-powertools/event-handler/http';
import type {
ALBEvent,
APIGatewayProxyEvent,
APIGatewayProxyEventV2,
Context,
LambdaFunctionURLEvent,
} from 'aws-lambda';
const app = new Router();
app.get('/hello', () => {
return {
message: 'Hello Event Handler!',
};
});
// Works across different services without any changes
export const restApiHandler = (event: APIGatewayProxyEvent, context: Context) =>
app.resolve(event, context);
export const httpApiHandler = (
event: APIGatewayProxyEventV2,
context: Context
) => app.resolve(event, context);
export const albHandler = (event: ALBEvent, context: Context) =>
app.resolve(event, context);
export const lambdaFunctionUrlHandler = (
event: LambdaFunctionURLEvent,
context: Context
) => app.resolve(event, context);Response Streaming
You can now stream responses directly from your Lambda functions, enabling use cases like serving large files, real-time data feeds, or progressive rendering. You just need to wrap your Router with streamify and you’re good to go.
import {
Router,
streamify,
} from '@aws-lambda-powertools/event-handler/http';
const app = new Router();
app.get('/video-stream', async (reqCtx) => {
reqCtx.res.headers.set('content-type', 'video/mp4');
return createVideoStream();
});
app.get('/hello', () => {
return { message: 'Hello World' };
});
export const handler = streamify(app);Binary Response
Event Handler now also includes first-class support for binary responses, making it straightforward to serve images, PDFs, or any other binary content from your Lambda functions. The utility handles the necessary encoding and content-type headers automatically.
import { createReadStream } from 'node:fs';
import { Router } from '@aws-lambda-powertools/event-handler/http';
import type { Context } from 'aws-lambda';
const app = new Router();
app.get('/logo', async (reqCtx) => {
reqCtx.res.headers.set('Content-Type', 'image/png');
return createReadStream(`${process.env.LAMBDA_TASK_ROOT}/logo.png`);
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);Changes
- feat(parser): add type for values parsed by DynamoDBStreamRecord (#4793) by @benthorner
- fix(event-handler): moved the response mutation logic to the
composeMiddlewarefunction (#4773) by @sdangol - feat(event-handler): add support for ALB (#4759) by @svozza
- test(maintenance): Expose ResponseStream object to simplify testing in event handler (#4753) by @svozza
- fix(event-handler): handle repeated queryString values (#4755) by @dreamorosi
- test(maintenance): remove unnecessary esbuild banner from e2e tests (#4745) by @svozza
- feat(event-handler): expose response streaming in public API (#4743) by @svozza
- fix(logger): infinite loop on log buffer when item size is max bytes (#4741) by @fidelisojeah
- fix(logger): not passing persistent keys to children (#4740) by @iamgerg
- fix(event-handler): allow event handler response to return array (#4725) by @arnabrahman
- feat(event-handler): add first-class support for binary responses (#4723) by @svozza
- feat(event-handler): Add support for HTTP APIs (API Gateway v2) (#4714) by @svozza
- chore(event-handler): unflag http handler from experimental (#4801) by @svozza
- feat(batch): use async local storage for batch processing (#4700) by @svozza
- feat(logger): use async local storage for logger (#4668) by @svozza
- feat(metrics): use async local storage for metrics (#4663) (#4694) by @svozza
- improv(commons): Make trace ID access more robust (#4693) by @svozza
📜 Documentation updates
- chore(ci): bumped the layer verison from 40 to 41 (#4800) by @sdangol
- docs(event-handler): added documentation for support for HTTP API, ALB and FURL (#4795) by @sdangol
- chore(deps): upgrade InvokeStore to v0.2.1 (#4794) by @svozza
- docs(event-handler): add response streaming docs (#4786) by @svozza
- chore(deps): bump mkdocs-llmstxt from 0.4.0 to 0.5.0 in /docs (#4789) by @dependabot[bot]
- docs(event-handler): update binary response docs (#4783) by @svozza
- docs(event-handler): updated docs for split router, catch all routes and error handler (#4779) by @sdangol
- chore(deps): bump @types/aws-lambda from 8.10.158 to 8.10.159 (#4771) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4769) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#4765) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 58 updates (#4761) by @dependabot[bot]
- docs(metrics): Improved documentation for adding dimensions (#4763) by @sdangol
- chore: add Codeac.io as customer reference (#4748) by @dreamorosi
- chore(deps-dev): bump markdownlint-cli2 from 0.18.1 to 0.19.0 (#4742) by @dependabot[bot]
- chore(deps): bump @types/node from 24.10.0 to 24.10.1 (#4738) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.157 to 8.10.158 (#4739) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.23 to 9.7.0 in /docs (#4733) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
58dee36to980e11fin /docs (#4731) by @dependabot[bot] - chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4728) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 72 updates (#4730) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.12 to 0.27.0 (#4729) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 38 updates (#4727) by @dependabot[bot]
- chore(deps): bump constructs from 10.4.2 to 10.4.3 (#4722) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4710) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.22 to 9.6.23 in /docs (#4704) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
f5c556ato58dee36in /docs (#4705) by @dependabot[bot] - chore(deps): bump the aws-sdk-v3 group across 1 directory with 89 updates (#4706) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.11 to 0.25.12 (#4707) by @dependabot[bot]
- chore(deps): bump @types/node from 24.9.2 to 24.10.0 (#4709) by @dependabot[bot]
- chore(deps): bump @types/node from 24.9.1 to 24.9.2 (#4699) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.156 to 8.10.157 (#4697) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4690) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 60 updates (#4688) by @dependabot[bot]
- docs: move the should i use this or Parser to the top of the validation (#4684) by @kawaaaas
- chore(ci): bumped the layer verison from 39 to 40 (#4683) by @svozza
🔧 Maintenance
- chore(deps): bump aws-xray-sdk-core from 3.11.0 to 3.12.0 (#4792) by @dependabot[bot]
- chore(deps): upgrade InvokeStore to v0.2.1 (#4794) by @svozza
- chore(deps): bump mkdocs-llmstxt from 0.4.0 to 0.5.0 in /docs (#4789) by @dependabot[bot]
- chore(deps): bump actions/checkout from 5.0.1 to 6.0.0 (#4788) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 16.2.6 to 16.2.7 (#4778) by @dependabot[bot]
- chore(de...
v2.28.1
Summary
This patch release addresses an issue in the Commons package utility introduced in v2.28.0 that caused a runtime error.
This issue affects only those who have lambda code that depends directly or indirectly on the getXrayTraceDataFromEnv function in the Commons package and who are bundling that lambda with ESBuild to an ES module.
We recommend updating to the latest version to avoid the issue.
Changes
📜 Documentation updates
- chore(ci): bumped the layer verison from 39 to 40 (#4683) by @svozza
- chore(deps): bump @types/node from 24.8.1 to 24.9.1 (#4673) by @dependabot[bot]
- chore(ci): bumped the layer verison from 38 to 39 (#4671) by @sdangol
🔧 Maintenance
- fix(logger): fix esbuild ESM bundler error (#4678) by @svozza
- chore(deps): bump @types/node from 24.8.1 to 24.9.1 (#4673) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 16.2.4 to 16.2.5 (#4672) by @dependabot[bot]
This release was made possible by the following contributors:
@dependabot[bot], @github-actions[bot], @sdangol, @svozza, dependabot[bot] and github-actions[bot]
v2.28.0
Summary
We are excited to announce that the REST API Event Handler now supports catch-all routes, allowing you to use regex patterns directly when defining route paths. We've also added the ability to split routers using includeRouter for both REST API and AppSync GraphQL Event Handlers.
We’ve also reverted the SQSRecordSchema change that caused failed parsing of records when md5OfMessageAttributes was null.
📜 Announcement: You can now find our documentation on the official AWS documentation domain at https://docs.aws.amazon.com/powertools/typescript/latest/
⭐ Congratulations @mdesousa, @thiagomeireless, @alex-karo for their first PR merged in the project 🎉
Catch-all route
You can now use regex patterns in your routes to handle arbitrary or deeply nested paths.
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
const app = new Router();
// Instead of defining every possible path
app.get('/files/:folder/:subfolder/:filename');
// Use regex to handle any depth
app.get(/\/files\/.*/, async (reqCtx) => {
// This will match:
// /files/docs/2025/report.pdf
// /files/images/avatars/user1/profile.jpg
// /files/any/number/of/nested/paths/file.txt
});We recommend having explicit routes whenever possible. Catch-all routes should be used sparingly and the pattern should be documented.
Split Routers
You can now define routes in separate files and import them into a main router file, improving code organization and maintainability.
REST API Event Handler
// userRoutes.ts
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
const userRouter = new Router();
userRouter.get('/', listUsers);
userRouter.post('/', createUser)
userRouter.get('/:id', getUser)
export { userRouter };// orderRoutes.ts
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
const orderRouter = new Router();
orderRouter.get('/orders', listOrders);
orderRouter.post('/orders', createOrder);
orderRouter.put('/orders/:id/status', updateStatus);
export { orderRouter };// main.ts
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
import type { APIGatewayProxyEvent } from 'aws-lambda';
import type { Context } from 'aws-lambda';
import { userRouter } from './userRoutes.js';
import { orderRouter } from './orderRoutes.js';
const app = new Router();
// Split Routers
app.includeRouter(userRouter, { prefix: '/users' });
app.includeRouter(orderRouter, { prefix: '/orders' });
export const handler = async (event: APIGatewayProxyEvent, context: Context) =>
app.resolve(event, context);AppSync GraphQL Event Handler
// postRouter.ts
import { Router } from '@aws-lambda-powertools/event-handler/appsync-graphql';
const postRouter = new Router();
postRouter.onQuery('getPosts', getPosts);
postRouter.onMutation('createPost', createPost);
export { postRouter };//userRouter.ts
import { Router } from '@aws-lambda-powertools/event-handler/appsync-graphql';
const userRouter = new Router();
userRouter.onQuery('getUsers', getUsers);
export { userRouter };// main.ts
import { AppSyncGraphQLResolver } from '@aws-lambda-powertools/event-handler/appsync-graphql';
import type { Context } from 'aws-lambda';
import { postRouter } from './postRouter';
import { userRouter } from './userRouter';
const app = new AppSyncGraphQLResolver();
app.includeRouter([postRouter, userRouter]);
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);Changes
- improv(event-handler): ended response stream when body is null (#4651) by @sdangol
- fix(idempotency): add null check for idempotencyHandler before calling handleMiddyOnError (#4643) by @mdesousa
- fix(parser): updated the SQSRecordSchema to make the md5OfMessageAttributes nullable (#4632) by @sdangol
- fix(event-handler): allow http handlers to return duplex streams (#4629) by @svozza
- fix(logger): correct persistentLogAttributes warning behavior (#4627) by @alex-karo
- feat(event-handler): added support for catch all route (#4582) by @sdangol
- improv(event-handler): rename ServiceError class to HttpError (#4610) by @svozza
- docs(parser): correct typos in example code for middleware (#4607) by @thiagomeireless
- test: update domain in e2e tests (#4606) by @dreamorosi
- ci: add
--deleteflag to docs publish command (#4584) by @dreamorosi - feat(event-handler): added
includeRoutermethod to split routes (#4573) by @sdangol - chore: sanitize CI inputs via env var (#4528) by @dreamorosi
- feat(event-handler): Add
includeRoutersupport to AppSync GraphQL resolver (#4457) by @arnabrahman
📜 Documentation updates
- chore(ci): bumped the layer verison from 38 to 39 (#4671) by @sdangol
- chore(deps): bump aws-cdk-lib from 2.219.0 to 2.220.0 in the aws-cdk group across 1 directory (#4665) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 88 updates (#4664) by @dependabot[bot]
- chore(deps): bump @types/node from 24.8.0 to 24.8.1 (#4661) by @dependabot[bot]
- chore(deps): bump @types/node from 24.7.2 to 24.8.0 (#4654) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.155 to 8.10.156 (#4653) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.10 to 0.25.11 (#4648) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.21 to 9.6.22 in /docs (#4647) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
00f9276tof5c556ain /docs (#4646) by @dependabot[bot] - chore(deps): bump the aws-sdk-v3 group across 1 directory with 49 updates (#4637) by @dependabot[bot]
- chore(deps): bump @types/node from 24.7.1 to 24.7.2 (#4642) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4638) by @dependabot[bot]
- chore(deps): bump @types/node from 24.7.0 to 24.7.1 (#4628) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.153 to 8.10.155 (#4617) by @dependabot[bot]
- chore: add AWS bootstrap js + update urls (#4614) by @dreamorosi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 99 updates (#4619) by @dependabot[bot]
- chore(deps): bump mkdocs-llmstxt from 0.3.2 to 0.4.0 in /docs (#4615) by @dependabot[bot]
- chore(deps): bump @types/node from 24.6.2 to 24.7.0 (#4618) by @dependabot[bot]
- chore(deps): bump @types/node from 24.6.1 to 24.6.2 (#4613) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4589) by @dependabot[bot]
- chore(deps): bump typescript from 5.9.2 to 5.9.3 in the typescript group across 1 directory (#4599) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
86d21dato00f9276in /docs (#4598) by @dependabot[bot] - chore(deps): bump @types/aws-lambda from 8.10.152 to 8.10.153 (#4600) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.20 to 9.6.21 in /docs (#4596) by @dependabot[bot]
- chore(deps): bump @types/node from 24.6.0 to 24.6.1 (#4601) by @dependabot[bot]
- chore(deps): bump @types/node from 24.5.2 to 24.6.0 (#4595) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 45 updates (#4592) by @dependabot[bot]
- docs: update install command for parser (#4585) by @dreamorosi
- chore(deps): bump tsx from 4.20.5 to 4.20.6 (#4580) by @dependabot[bot]
- ci: improve linting checks (#4545) by @dreamorosi
- chore(ci): update layer ARN on documentation (#4535) by @sdangol
🔧 Maintenance
- chore(deps-dev): bump lint-staged from 16.2.4 to 16.2.5 (#4672) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.219.0 to 2.220.0 in the aws-cdk group across 1 directory (#4665) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 4.30.8 to 4.30.9 (#4666) by @dependabot[bot]
- feat(metrics): use async local storage for metrics (#4663) by @svozza
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 88 updates (#4664) by @dependabot[bot]
- chore(deps): bump @types/node from 24.8.0 to 24.8.1 (#4661) by @dependabot[bot]
- chore: update CONTRIBUTING.md (#4659) by @ConnorKirk
- improv(commons): Make X-Ray trace ID access more robust (#4658) by @svozza
- chore(deps): bump @types/node from 24.7.2 to 24.8.0 (#4654) by @dependabot[bot]
- chore(deps): bump aws-xray-sdk-core from 3.10.3 to 3.11.0 (#4656) by @[dependabot[bot]](https://github.com...
v2.27.0
Summary
We're excited to announce an update to our Event Handler utility, featuring new middleware for CORS (Cross-Origin Resource Sharing) configuration and automatic response compression. We have also added support for Route Prefixes which allows you to avoid repeating a shared prefix in each route definition.
We've listened to your feedback and also made some slight changes to the type signature in the handlers to improve developer experience.
We have also made the error handlers more versatile by allowing a Response object or a JavaScript object to be returned from the error handler.
⭐ Congratulations @guillemcomerma for their first PR merged in the project, and thank you to @shrivarshapoojari and @dani-abib for their contributions 🎉
CORS Middleware
The CORS middleware ensures CORS headers are returned as part of the response when your functions match the path invoked and the Origin matches one of the allowed values.
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
import { cors } from '@aws-lambda-powertools/event-handler/experimental-rest/middleware';
import type { Context } from 'aws-lambda';
const app = new Router();
app.use(
cors({
origin: 'https://example.com',
maxAge: 300,
})
);
app.get('/todos/:todoId', async ({ params: { todoId } }) => {
const todo = await getTodoById(todoId);
return { todo };
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);
/**
When invoked from a valid origin, this returns:
{
"statusCode": 200,
"headers": {
"access-control-allow-credentials": "false",
"access-control-allow-origin": "https://example.com",
"content-type": "application/json"
},
"multiValueHeaders": {
"access-control-allow-headers": [
"Authorization",
"Content-Type",
"X-Amz-Date",
"X-Api-Key",
"X-Amz-Security-Token"
],
"access-control-allow-methods": [
"DELETE",
"GET",
"HEAD",
"PATCH",
"POST",
"PUT"
]
},
"body": "{\"todoId\":\"123\",\"task\":\"Example task\",\"completed\":false}",
"isBase64Encoded": false
}
**/Compress Middleware
The compress middleware automatically compresses responses using gzip and base64 encodes them when the client indicates support via the Accept-Encoding header.
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
import { compress } from '@aws-lambda-powertools/event-handler/experimental-rest/middleware';
import type { Context } from 'aws-lambda';
const app = new Router();
app.use(compress());
app.get('/todos/:todoId', async ({ params: { todoId } }) => {
const todo = await getTodoById(todoId);
return { todo };
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);
/**
When invoked with the following request,
{
"headers": {
"Accept-Encoding": "gzip"
},
"resource": "/todos/1",
"path": "/todos/1",
"httpMethod": "GET"
}
it would return,
{
"statusCode": 200,
"multiValueHeaders": {
"Content-Type": [
"application/json"
],
"Content-Encoding": [
"gzip"
]
},
"body": "H4sIAAAAAAACE42STU4DMQyFrxJl3QXln96AMyAW7sSDLCVxiJ0Kqerd8TCCUOgii1EmP/783pOPXjmw+N3L0TfB+hz8brvxtC5KGtHvfMCIkzZx0HT5MPmNnziViIr2dIYoeNr8Q1x3xHsjcVadIbkZJoq2RXU8zzQROLseQ9505NzeCNQdMJNBE+UmY4zbzjAJhWtlZ57sB84BWtul+rteH2HPlVgWARwjqXkxpklK5gmEHAQqJBMtFsGVygcKmNVRjG0wxvuzGF2L0dpVUOKMC3bfJNjJgWMrCuZk7cUp02AiD72D6WKHHwUDKbiJs6AZ0VZXKOUx4uNvzdxT+E4mLcMA+6G8nzrLQkaxkNEVrFKW2VGbJCoCY7q2V3+tiv5kGThyxfTecDWbgGz/NfYXhL6ePgF9PnFdPgMAAA==",
"isBase64Encoded": true
}
**/Route Prefixes
When defining multiple routes related to a specific resource, you can use the prefix constructor parameter when creating a new Router instance, and we'll automatically strip it from the request path before matching routes. This will prevent you to avoid repeating the prefix in each route definition.
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
import type { Context } from 'aws-lambda';
const app = new Router({ prefix: '/todos' });
// matches POST /todos
app.post('/', async ({ req: { headers } }) => {
const todos = await getUserTodos(headers.get('Authorization'));
return { todos };
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);Type Signature Changes
We’ve also made changes to some type signatures to reduce parameter complexity.
The path parameters in the route handlers have been moved to reqCtx
app.get('/todos/:todoId', async (reqCtx) => {
return { id: reqCtx.params.todoId };
});
Previously middleware used positional arguments:
const middleware: Middleware = async (params, reqCtx, next) => {
logger.info('Request processed');
await next();
};Now, we have changed it to be an object so customers can pick only the parameters that they want and also moved the params parameter to reqCtx
const middleware: Middleware = async ({ reqCtx: { params }, next }) => {
logger.info('Request processed');
await next();
};We have also changed the request property to req in the RequestContext type to maintain consistency with the res property.
Improvements on Error Handling
Error handlers can now return a Response object or a JavaScript object that will be auto-serialized.
import {
HttpStatusCodes,
Router,
} from '@aws-lambda-powertools/event-handler/experimental-rest';
import { Logger } from '@aws-lambda-powertools/logger';
import type { Context } from 'aws-lambda/handler';
const logger = new Logger();
const app = new Router({ logger });
app.errorHandler(GetTodoError, async (error, reqCtx) => {
logger.error('Unable to get todo', { error });
return {
statusCode: HttpStatusCodes.BAD_REQUEST,
message: `Bad request: ${error.message} - ${reqCtx.req.headers.get('x-correlation-id')}`,
};
});
app.get('/todos/:todoId', async ({ params: { todoId } }) => {
const todo = await getTodoById(todoId); // May throw GetTodoError
return { todo };
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);Changes
- chore: sanitize CI inputs via env var (#4528) by @dreamorosi
- improv(event-handler): rename HttpErrorCodes to HttpStatusCodes (#4543) by @dreamorosi
- docs(idempotency): fix dataKeywordArgument reference and remove unused test code (#4537) by @guillemcomerma
- improv(event-handler): made error handler responses versatile (#4536) by @sdangol
- chore(ci): add
registry-urltosetup-nodesteps to fix Scorecard packaging check (#4539) by @shrivarshapoojari - improv(event-handler): changed path parameter in middleware and routehandler signature (#4532) by @sdangol
- improv(event-handler): changed the Middleware and RequestContext signatures (#4530) by @sdangol
- fix(event-handler): fixed CORS behaviour not aligned with CORS spec (#4512) by @sdangol
- feat(event-handler): implemented route prefixes in HTTP event handler (#4523) by @sdangol
- feat(event-handler): throw error when middleware does not await next() (#4511) by @svozza
- chore: always append
PTEnvto UA string (#4522) by @dreamorosi - fix(event-handler): run global middleware on all requests for REST API (#4507) by @svozza
- fix(batch): fixed the build issue with Batch processor due to missing dependencies (#4498) by @sdangol
- feat(event-handler): added compress middleware for the REST API event handler (#4495) by @sdangol
- feat(event-handler): add CORS middleware support (#4477) by @dcabib
📜 Documentation updates
- chore(ci): update layer ARN on documentation (#4535) by @sdangol
- docs(event-handler): update to new APIs before release (#4542) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4527) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 62 updates (#4526) by @dependabot[bot]
- docs(event-handler): general improvements (#4517) by @dreamorosi
- chore(deps): bump esbuild from 0.25.9 to 0.25.10 (#4503) by @dependabot[bot]
- chore(deps): bump @types/node from 24.5.1 to 24.5.2 (#4505) by @dependabot[bot]
- chore(deps): bump mkdocs-llmstxt from 0.3.1 to 0.3.2 in /docs (#4508) by @dependabot[bot]
- chore(deps): bump @types/node from 24.5.0 to 24.5.1 (#4501) by @dependabot[bot]
- fix(batch): fixed the build issue with Batch processor due to missing dependencies (#4498) by @sdangol
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 88 updates (#4494) by @dependabot[bot]
- chore(deps): bump @types/node from 24.4.0 to 24.5.0 (#4497) by @dependabot[bot]
- chore(deps): bump @types/node from 24.3.1 to 24.4.0 (#4493) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.19 to 9.6.20 in /docs (#4492) by @[...