Releases: aws-powertools/powertools-lambda-typescript
v2.25.1
Summary
This is a patch release that addresses an issue with the logger and the idempotency package introduced in v2.25.0
that could potentially affect users’ tests in some circumstances. This does not affect any production workloads.
Furthermore, it also fixes an issue with the tracer package which caused a deprecation warning when @tracer.captureLambdaHandler()
was used.
We recommend updating to this version if you're currently using v2.25.0
, especially if you're experiencing any test-related issues.
⭐ Congratulations @MaxOpperman, @BeckettFrey for their first PRs merged in the project 🎉
Changes
- ci: bump version-n-release GitHub Action and modify input values (#4330) by @dreamorosi
- improv(idempotency): Prevent error when AWS_LAMBDA_FUNCTION_NAME is not passed in the Idempotency Persistence Layer (#4327) by @sdangol
- improv(logger): resolve issue when no logger region is set (#4319) by @MaxOpperman
- improv(ci): Skip Layer version checks for the Gamma environment (#4321) by @sdangol
- refactor: idempotency env service to functions 4246 (#4314) by @BeckettFrey
- fix(tracer): pass args of decorated method as they are (#4312) by @dreamorosi
📜 Documentation updates
- chore(ci): update layer ARN on documentation (#4337) by @svozza
- docs: add FraudFalcon customer reference (#4332) by @dreamorosi
- chore(deps): bump esbuild from 0.25.8 to 0.25.9 (#4325) by @dependabot[bot]
- chore(deps): bump tsx from 4.20.3 to 4.20.4 (#4313) by @dependabot[bot]
🔧 Maintenance
- docs: add FraudFalcon customer reference (#4332) by @dreamorosi
- chore(deps): bump esbuild from 0.25.8 to 0.25.9 (#4325) by @dependabot[bot]
- chore(deps-dev): bump @redis/client from 5.8.0 to 5.8.1 (#4324) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.29.8 to 3.29.9 (#4315) by @dependabot[bot]
- chore(deps): bump tsx from 4.20.3 to 4.20.4 (#4313) by @dependabot[bot]
This release was made possible by the following contributors:
@BeckettFrey, @MaxOpperman, @dependabot[bot], @dreamorosi, @github-actions[bot], @sdangol, @svozza, dependabot[bot] and github-actions[bot]
v2.25.0
Summary
We have discontinued support for Node.js 18 with this release. All users are strongly encouraged to upgrade to Node.js 20 or later to ensure continued compatibility and security updates.
The parse
function is now exported from the Parser package. This addition enables manual parsing in scenarios such as validating query string parameters, offering more flexibility in data handling and validation.
We’ve also fixed a bug with the Zod schema for the Cognito Trigger Event in the parser.
Furthermore, we have been working on the improvements in the overall code quality and maintainability of the codebase.
⭐ Congratulations @dwrth, @bdellegrazie, @jaimellamasi for their first PRs merged in the project 🎉
Parse Function
import { parse } from '@aws-lambda-powertools/parser';
export const handler = async (event: APIGatewayEvent) => {
try {
const querySchema = z.object({
id: z.string()
});
const params = parse(event.queryStringParameters, undefined, querySchema);
} catch(error) {
console.error("Failed to parse the query string parameters");
}
}
Before this release, it was only possible to use the parser through middleware or a decorator.
To use the parse
function, simply pass the payload to be parsed, the envelope (if required), the schema, and the optional safe parse flag.
Changes
- feat(event-handler): add event handler registry (#4307) by @svozza
- feat(event-handler): add error classes for http errors (#4299) by @svozza
- feat(parser): Exported the parse function from the parser (#4300) by @sdangol
- feat(event-handler): implement route matching & resolution system for rest handler (#4297) by @svozza
- refactor(idempotency): fix code quality issues (#4298) by @dwrth
- improv(deps): Decrease the update schedule of aws-cdk and aws-sdk-v3 group in dependabot (#4290) by @sdangol
- refactor(commons): fix code quality issues (#4292) by @dwrth
- refactor(jmespath): fix code quality issues (#4286) by @dwrth
- refactor(batch): improve code quality in test handlers (#4281) by @dwrth
- refactor(logger): replace EnvironmentVariablesService class with helper functions (#4251) by @jaimellamasi
- test(event-handler): coverage 100% for AppSync GraphQL (#4261) by @dreamorosi
- refactor(kafka): improve tests & error handling (#4262) by @dreamorosi
- refactor(tracer): fix code quality issues (#4264) by @dwrth
- fix(parser): cognito schema
preferredRole
may be null (#4259) by @bdellegrazie - ci: update version-n-changelog action & input (#4258) by @dreamorosi
- feat(event-handler): add support for AppSync GraphQL batch resolvers (#4218) by @arnabrahman
📜 Documentation updates
- chore(deps): Bumped the version to 2.25.0 (#4310) by @sdangol
- improv(ci): Verify Output of Layer Deployment (Partitions) GitHub Action (#4308) by @sdangol
- chore(deps): bump @types/node from 24.2.0 to 24.2.1 (#4304) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 34 updates (#4305) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.209.1 to 2.210.0 in the aws-cdk group across 1 directory (#4285) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4294) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4284) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4278) by @dependabot[bot]
- chore(deps): bump mkdocs-llmstxt from 0.3.0 to 0.3.1 in /docs (#4277) by @dependabot[bot]
- docs: update maintainers & PR template (#4274) by @dreamorosi
- chore(deps): bump @types/node from 24.1.0 to 24.2.0 (#4271) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 10 updates (#4270) by @dependabot[bot]
- chore(deps): bump the typescript group across 1 directory with 2 updates (#4268) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4244) by @dependabot[bot]
- chore: drop Node.js 18 support (#4243) by @dreamorosi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4241) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.207.0 to 2.208.0 in the aws-cdk group across 1 directory (#4237) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
0bfdba4
tobb7b015
in /docs (#4224) by @dependabot[bot] - chore(deps): bump mkdocs-material from 9.6.15 to 9.6.16 in /docs (#4230) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4232) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4209) by @dependabot[bot]
🔧 Maintenance
- chore(deps): Bumped the version to 2.25.0 (#4310) by @sdangol
- improv(ci): Verify Output of Layer Deployment (Partitions) GitHub Action (#4308) by @sdangol
- chore(deps): bump actions/checkout from 4.2.2 to 5.0.0 (#4301) by @dependabot[bot]
- chore(deps): bump @types/node from 24.2.0 to 24.2.1 (#4304) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 34 updates (#4305) by @dependabot[bot]
- chore(deps-dev): bump the typescript group across 1 directory with 2 updates (#4303) by @dependabot[bot]
- chore(deps-dev): bump zod from 4.0.15 to 4.0.17 (#4302) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 32 updates (#4296) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.209.1 to 2.210.0 in the aws-cdk group across 1 directory (#4285) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 16.1.4 to 16.1.5 (#4295) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.29.7 to 3.29.8 (#4293) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4294) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.1.3 to 2.1.4 (#4289) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4284) by @dependabot[bot]
- chore(deps): bump actions/download-artifact from 4.3.0 to 5.0.0 (#4280) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4278) by @dependabot[bot]
- chore(deps-dev): bump zod from 4.0.14 to 4.0.15 (#4279) by @dependabot[bot]
- chore(deps): bump mkdocs-llmstxt from 0.3.0 to 0.3.1 in /docs (#4277) by @dependabot[bot]
- chore(deps-dev): bump @redis/client from 5.7.0 to 5.8.0 (#4276) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 16.1.2 to 16.1.4 (#4275) by @dependabot[bot]
- chore(deps): bump aws-actions/configure-aws-credentials from 4.2.1 to 4.3.1 (#4272) by @dependabot[bot]
- docs: update maintainers & PR template (#4274) by @dreamorosi
- chore(deps): bump @types/node from 24.1.0 to 24.2.0 (#4271) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 10 updates (#4270) by @dependabot[bot]
- chore(deps): bump the typescript group across 1 directory with 2 updates (#4268) by @dependabot[bot]
- chore(deps): update typedoc to v0.28.9 (#4267) by @svozza
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4244) by @dependabot[bot]
- chore: drop Node.js 18 support (#4243) by @dreamorosi
- chore(deps-dev): bump @redis/client from 5.6.1 to 5.7.0 (#4242) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4241) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.207.0 to 2.208.0 in the aws-cdk group across 1 directory (#4237) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.29.4 to 3.29.5 (#4236) by @dependabot[bot]
- test(parser): Fixed failing tests after zod version bump to 4.0.14 (#4240) by @sdangol
- chore(deps-dev): bump @biomejs/biome from 2.1.2 to 2.1.3 (#4238) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
0bfdba4
tobb7b015
in /docs (#4224) by @dependabot[bot] - chore(deps): bump mkdocs-material from 9.6.15 to 9.6.16 in /docs (#4230) by @[dependabot[bot]](https://github.com/ap...
v2.24.1
Summary
In this release we have improved runtime validations in the Metrics utility, ensuring that invalid metrics are not sent to CloudWatch and avoiding data loss.
Furthermore, we now only support Zod 4.x. Using Zod 3.x with the Parser utility will result in a build-time error.
⭐ Congratulations @JonkaSusaki and @uttam282005 for their first PRs merged in the project 🎉
Metrics Runtime Validations
Before this release, if you published invalid metrics they could fail silently, leading to data loss. Now Lambda will throw an error if the following constraints do not hold:
- Metric Name: Validated according to CloudWatch constraints
- Metric Value: Validated for numeric values
- Metric Unit: Validated for allowed units
- Metric Resolution: Validated for allowed resolutions
- Dimension Name: Both Dimension name and value are validated for non empty, non-null values.
Changes
- fix(metrics): revert changes when raise warning with overridden default dimensions (#4226) by @svozza
- fix(metrics): emit warning when default dimensions are overwritten (#4222) by @uttam282005
- refactor(event-handler): replace EnvironmentVariablesService class with helper functions in Event Handler (#4225) by @JonkaSusaki
- ci: fix version output interpolation in make-version workflow (#4220) by @dreamorosi
- ci: set version number correctly when versioning (#4219) by @dreamorosi
- feat(event-handler): add route management system for ApiGw event handler (#4211) by @svozza
- ci: update
make-release.yml
workflow to use latest upstream (#4215) by @dreamorosi - ci: remove local create-pr action (#4213) by @dreamorosi
- improv(maintenance): Removed some unused assignments and added missing error handling (#4208) by @sdangol
- ci: remove
lerna version
(#4201) by @dreamorosi - refactor(ci): Updated the publish command in the CI to use
npm publish
instead oflerna publish
(#4195) by @sdangol - refactor(metrics): replace EnvironmentVariablesService with cached #envConfig (#4188) by @uttam282005
- improv(metrics): Added runtime validations for the metrics utility functions (#4181) by @sdangol
- refactor(parameters): replace EnvironmentVariablesService class with helper functions in Parameters (#4168) by @JonkaSusaki
🌟New features and non-breaking changes
- feat(event-handler): add base router class (#3972) by @dreamorosi
📜 Documentation updates
- chore(ci): bump version to 2.24.1 (#4231) by @sdangol
- chore(deps): bump @types/aws-lambda from 8.10.150 to 8.10.152 (#4205) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.6 to 0.25.8 (#4200) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 2 updates (#4192) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.14 to 24.1.0 (#4193) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4186) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4183) by @dependabot[bot]
- docs: update release steps in maintainers section (#4180) by @svozza
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4178) by @dependabot[bot]
- chore(deps): bump mkdocs-llmstxt from 0.2.0 to 0.3.0 in /docs (#4175) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.204.0 to 2.205.0 in the aws-cdk group across 1 directory (#4173) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.13 to 24.0.14 (#4174) by @dependabot[bot]
🔧 Maintenance
- chore(ci): bump version to 2.24.1 (#4231) by @sdangol
- chore(deps): bump @types/aws-lambda from 8.10.150 to 8.10.152 (#4205) by @dependabot[bot]
- chore(deps-dev): bump @redis/client from 5.6.0 to 5.6.1 (#4207) by @dependabot[bot]
- chore(deps): Removed the lerna dependency and all the usage of it (#4202) by @sdangol
- chore(deps): bump @aws-sdk/client-lambda from 3.848.0 to 3.851.0 in the aws-sdk-v3 group across 1 directory (#4199) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.29.3 to 3.29.4 (#4198) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.6 to 0.25.8 (#4200) by @dependabot[bot]
- fix(parser): set zod peer range to 4.x (#4196) by @dreamorosi
- chore(deps): bump github/codeql-action from 3.29.2 to 3.29.3 (#4194) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 2 updates (#4192) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.14 to 24.1.0 (#4193) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4186) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 2.1.1 to 2.1.2 (#4187) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4183) by @dependabot[bot]
- docs: update release steps in maintainers section (#4180) by @svozza
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4178) by @dependabot[bot]
- chore(deps): bump mkdocs-llmstxt from 0.2.0 to 0.3.0 in /docs (#4175) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.204.0 to 2.205.0 in the aws-cdk group across 1 directory (#4173) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.13 to 24.0.14 (#4174) by @dependabot[bot]
This release was made possible by the following contributors:
@JonkaSusaki, @dependabot[bot], @dreamorosi, @github-actions[bot], @sdangol, @svozza, @uttam282005, dependabot[bot] and github-actions[bot]
v2.24.0
Summary
We’ve listened to your feedback and starting from this release of Parser we support only Zod v4 for all our built-in schemas and envelopes. Additionally the utility got a power up and it now supports schemas written using Standard Schema 🔥.
We’ve also fixed a bug in Tracer that prevented requests made via proxies to be traced correctly and another bug in Metrics that caused dimension sets to be added correctly to the metrics data object..
🌟 Congratulations to @chetan9518, @sdangol, and @matteofigus for their first PRs merged in the project 🎉
Using Parser with Standard Schema
You can now use schemas written using Valibot or other Standard Schema-compatible parsing library to parse incoming events using the parser
Middy.js middleware or TypeScript class method decorator. This is useful if your codebase is already relying on one of these libraries or you want to have full control over the bundle size.
Note that our built-in schemas and envelopes are still defined only using Zod. If you would like us to support other libraries like Valibot please open an issue and we will consider it based on the community's feedback.
If you are using Zod v3 and need more time to migrate, you can continue using Parser v2.23.0 as long as needed.
import { Logger } from '@aws-lambda-powertools/logger';
import { parser } from '@aws-lambda-powertools/parser/middleware';
import middy from '@middy/core';
import {
array,
number,
object,
optional,
pipe,
string,
toMinValue,
} from 'valibot';
const logger = new Logger();
const orderSchema = object({
id: pipe(number(), toMinValue(0)),
description: string(),
items: array(
object({
id: pipe(number(), toMinValue(0)),
quantity: pipe(number(), toMinValue(1)),
description: string(),
})
),
optionalField: optional(string()),
});
export const handler = middy()
.use(parser({ schema: orderSchema }))
.handler(async (event): Promise<void> => {
for (const item of event.items) {
logger.info('Processing item', { item });
}
});
Tracing requests using a proxy
You can now correctly trace outbound requests made via proxies. Tracer will detect the CONNECT request made to the proxy and intelligently exclude it from the trace data, leaving only the segment for the main request to avoid creating noise in your traces.
import { Tracer } from "@aws-lambda-powertools/tracer";
import { getSecret } from "@aws-lambda-powertools/parameters/secrets";
import { captureLambdaHandler } from "@aws-lambda-powertools/tracer/middleware";
import middy from "@middy/core";
import { ProxyAgent } from "undici";
const tracer = new Tracer({
serviceName: "tracerproxy",
});
const client = new ProxyAgent({
uri: "http://proxy:8080",
token: await getSecret('/dev/proxy-token'),
});
export const handler = middy()
.use(captureLambdaHandler(tracer))
.handler(async () => {
try {
const res = await fetch("https://foo.com", {
dispatcher: client,
signal: AbortSignal.timeout(2000),
});
console.debug("Response status:", res.status);
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}
} catch (error) {
console.error("Error fetching URL:", error);
if (error instanceof HttpError) {
return {
statusCode: error.code,
};
}
return {
statusCode: 500,
};
}
return {
statusCode: 200,
};
});
Adding dimension sets to metrics
You can create separate dimension sets for your metrics using the addDimensions()
method. This allows you to group metrics by different dimension combinations.
Starting from this release, when you use this method, we’ll create a new dimension set rather than adding to the existing dimensions - the previous behavior was incorrect and didn’t allow you to track the same metric across different dimension combinations.
import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
const metrics = new Metrics({
namespace: 'serverlessAirline',
serviceName: 'orders',
});
export const handler = async (
_event: unknown,
_context: unknown
): Promise<void> => {
// Add a single dimension
metrics.addDimension('environment', 'prod');
// Add a new dimension set
metrics.addDimensions({
dimension1: '1',
dimension2: '2',
});
// Add another dimension set
metrics.addDimensions({
region: 'us-east-1',
category: 'books',
});
// Add metrics
metrics.addMetric('successfulBooking', MetricUnit.Count, 1);
metrics.publishStoredMetrics();
};
Changes
- fix(parser): Removed the nullable type from the md5OfMessageAttributes in SqsRecordSchema (#4165) by @sdangol
- chore(parser): remove deprecated parser type (#4154) by @dreamorosi
- refactor(metrics): optimize
addDimensions
method to avoid O(n²) complexity (#4156) by @dreamorosi - chore: fix typo in partitioned layers workflow (#4126) by @dreamorosi
🌟New features and non-breaking changes
- feat(event-handler): add base router class (#3972) by @dreamorosi
📜 Documentation updates
- chore: bump to 2.24.0 (#4172) by @dreamorosi
- chore(deps): bump @types/node from 24.0.12 to 24.0.13 (#4167) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.5 to 0.25.6 (#4166) by @dependabot[bot]
- feat(parser): support Standard Schema and upgrade to Zod v4 (#4164) by @dreamorosi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4159) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.10 to 24.0.12 (#4157) by @dependabot[bot]
- chore(batch): exclude deprecated code from coverage (#4152) by @dreamorosi
- docs(idempotency): simplify snippets (#4150) by @dreamorosi
- fix(tracer): skip tracing CONNECT requests (#4148) by @dreamorosi
- chore(deps): bump aws-cdk-lib from 2.203.1 to 2.204.0 in the aws-cdk group across 1 directory (#4143) by @dependabot[bot]
- chore: bump biome formatter to next major & reformat (#4145) by @dreamorosi
- docs: update roadmap with completed features and Discord badge (#4133) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4129) by @dependabot[bot]
- fix(metrics): addDimensions() documentation and tests (#3964) by @matteofigus
- chore(deps): bump @types/node from 24.0.8 to 24.0.10 (#4119) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4118) by @dependabot[bot]
🐛 Bug and hot fixes
- fix(metrics): addDimensions() documentation and tests (#3964) by @matteofigus
🔧 Maintenance
- chore: bump to 2.24.0 (#4172) by @dreamorosi
- chore(deps): bump @types/node from 24.0.12 to 24.0.13 (#4167) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.5 to 0.25.6 (#4166) by @dependabot[bot]
- feat(parser): support Standard Schema and upgrade to Zod v4 (#4164) by @dreamorosi
- chore(deps-dev): bump @redis/client from 5.5.6 to 5.6.0 (#4162) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4159) by @dependabot[bot]
- chore(deps): bump vscode/devcontainers/javascript-node from
0d29e5f
toeac37fb
in /.devcontainer (#4161) by @dependabot[bot] - chore(deps-dev): bump zod from 3.25.67 to 3.25.76 (#4158) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.10 to 24.0.12 (#4157) by @dependabot[bot]
- refactor(tracer): replace class-based env access with functional helpers (#4146) by @chetan9518
- chore(deps): bump aws-cdk-lib from 2.203.1 to 2.204.0 in the aws-cdk group across 1 directory (#4143) by @dependabot[bot]
- chore(deps-dev): bump @biomejs/biome from 1.9.4 to 2.1.0 (#4147) by @dependabot[bot]
- chore: bump biome formatter to next major & reformat (#4145) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4129) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.8 to 24.0.10 (#4119) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4118) by @dependabot[bot]
- chore(deps-dev): bump @aws-sdk/client-cloudwatch from 3.840.0 to 3.841.0 in the aws-sdk-v3 group across 1 directory (#4117) by @[dependabot[bot]](http...
v2.23.0
Summary
We're excited to announce a new resolver for AppSync GraphQL APIs in the Event Handler utility. It simplifies routing and processing of events in AWS Lambda functions by allowing you to define resolvers for specific GraphQL types and fields.
We’ve also fixed two bugs in Logger: 1/ one causing timestamps to be incorrectly formatted when using non-UTC timezone and around midnight, and 2/ another causing temporary keys to not be properly cleared when using the injectLambdaContext()
Middy.js middleware.
Finally, starting from this release we're publishing our Lambda layers in the AWS China Beijing Region operated by Sinnet.
🌟 A huge thank you to @arnabrahman for the amazing work on the AppSync GraphQL resolver 🎉
Working AppSync GraphQL APIs
Key Features
- Route events based on GraphQL type and field keys
- Automatically parse API arguments to function parameters
- Handle GraphQL responses and errors in the expected format
To get started install the Event Handler utility by running:
npm install @aws-lambda-powertools/event-handler
Registering a resolver
You can register functions to match GraphQL types and fields with one of three methods:
onQuery()
- Register a function to handle a GraphQL Query type.onMutation()
- Register a function to handle a GraphQL Mutation type.resolver()
- Register a function to handle a GraphQL type and field.
Your resolvers receive the parsed arguments from the GraphQL request as their first parameter. We will take care of parsing the response or catching errors and returning them in the expected format.
You can register a resolver for a Query
type, you can use the onQuery()
method. This method allows you to define a function that will be invoked when a GraphQL Query is made.
import { AppSyncGraphQLResolver } from '@aws-lambda-powertools/event-handler/appsync-graphql';
import { Logger } from '@aws-lambda-powertools/logger';
import type { Context } from 'aws-lambda';
const logger = new Logger({
serviceName: 'TodoManager',
});
const app = new AppSyncGraphQLResolver({ logger });
app.onQuery<{ id: string }>('getTodo', async ({ id }) => {
logger.debug('Resolving todo', { id });
// Simulate fetching a todo from a database or external service
return {
id,
title: 'Todo Title',
completed: false,
};
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);
Use the onMutation()
method to process GraphQL mutations:.
import {
AppSyncGraphQLResolver,
makeId,
} from '@aws-lambda-powertools/event-handler/appsync-graphql';
import { Logger } from '@aws-lambda-powertools/logger';
import type { Context } from 'aws-lambda';
const logger = new Logger({
serviceName: 'TodoManager',
});
const app = new AppSyncGraphQLResolver({ logger });
app.onMutation<{ title: string }>('createTodo', async ({ title }) => {
logger.debug('Creating todo', { title });
const todoId = makeId();
// Simulate creating a todo in a database or external service
return {
id: todoId,
title,
completed: false,
};
});
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);
When you want to have more control over the type and field, you can use the resolver()
method. This method allows you to register a function for a specific GraphQL type and field including custom types.
import { AppSyncGraphQLResolver } from '@aws-lambda-powertools/event-handler/appsync-graphql';
import { Logger } from '@aws-lambda-powertools/logger';
import type { Context } from 'aws-lambda';
const logger = new Logger({
serviceName: 'TodoManager',
});
const app = new AppSyncGraphQLResolver({ logger });
app.resolver(
async () => {
logger.debug('Resolving todos');
// Simulate fetching a todo from a database or external service
return [
{
id: 'todo-id',
title: 'Todo Title',
completed: false,
},
{
id: 'todo-id-2',
title: 'Todo Title 2',
completed: true,
},
];
},
{
fieldName: 'listTodos',
typeName: 'Query',
}
);
export const handler = async (event: unknown, context: Context) =>
app.resolve(event, context);
The resolver includes helper functions for working with AppSync scalar values (basic data types like String, Int, Boolean). These helpers simplify data type conversion and validation when processing GraphQL requests. To learn more check out the documentation page.
Lambda Layers in AWS China (Beijing) Region
Powertools for AWS Lambda (TypeScript) layers are now available in the AWS China Beijing Region operated by Sinnet.
Region | Location | ARN |
---|---|---|
cn-north-1 |
Beijing | arn:aws-aws-cn:lambda:cn-north-1:498634801083:layer:AWSLambdaPowertoolsTypeScriptV2:30 |
You can use the AWS CLI to inspect the contents of the layer and read its metadata:
aws lambda get-layer-version-by-arn --arn arn:aws-aws-cn:lambda:cn-north-1:498634801083:layer:AWSLambdaPowertoolsTypeScriptV2:30 --region cn-north-1
Changes
- chore: fix typo in partitioned layers workflow (#4126) by @dreamorosi
- fix(logger): reset keys on error in middleware (#4122) by @dreamorosi
- feat(event-handler): expose event & context as object (#4113) by @dreamorosi
- fix(logger): set
hourCycle
to h23 when tz is not UTC (#4102) by @dreamorosi - feat(event-handler): add single resolver functionality for AppSync GraphQL API (#3999) by @arnabrahman
📜 Documentation updates
- chore(deps): bump @types/node from 24.0.8 to 24.0.10 (#4119) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4118) by @dependabot[bot]
- docs(event-handler): add AppSync GraphQL docs page (#4120) by @dreamorosi
- chore(deps): bump @types/node from 24.0.7 to 24.0.8 (#4107) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4106) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.14 to 9.6.15 in /docs (#4104) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
eb04b60
to0bfdba4
in /docs (#4105) by @dependabot[bot] - chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4108) by @dependabot[bot]
- docs: clarify version mismatch risks (#4103) by @dreamorosi
- chore(deps): bump @types/node from 24.0.4 to 24.0.7 (#4099) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4098) by @dependabot[bot]
- docs: update layers version + simplify script (#4096) by @leandrodamascena
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4087) by @dependabot[bot]
- docs(kafka): provide example payloads (#4094) by @dreamorosi
- chore(deps): bump @types/node from 24.0.3 to 24.0.4 (#4088) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4085) by @dependabot[bot]
- fix(ci): Partition workflows (#4084) by @sthulb
- docs(batch): clarify ordering/async processing (#4081) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4078) by @dependabot[bot]
🔧 Maintenance
- chore(deps): bump @types/node from 24.0.8 to 24.0.10 (#4119) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4118) by @dependabot[bot]
- chore(deps-dev): bump @aws-sdk/client-cloudwatch from 3.840.0 to 3.841.0 in the aws-sdk-v3 group across 1 directory (#4117) by @dependabot[bot]
- docs(event-handler): add AppSync GraphQL docs page (#4120) by @dreamorosi
- feat(event-handler): support
onQuery
andonMutation
handlers (#4111) by @dreamorosi - chore(deps): bump @types/node from 24.0.7 to 24.0.8 (#4107) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4106) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.14 to 9.6.15 in /docs (#4104) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
eb04b60
to0bfdba4
in /docs (#4105) by @dependabot[bot] - chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4108) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.4 to 24.0.7 (#4099) by @dependabot[bot]
- chore(deps-dev): bump typedoc from 0.28.5 to 0.28.6 in the typescript group across 1 directory (#4090) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4098) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.29.0 to ...
v2.22.0
Summary
We're excited to announce the Kafka Consumer utility, which transparently handles message deserialization, provides an intuitive developer experience, and integrates seamlessly with the rest of the Powertools for AWS Lambda ecosystem.
Key features
- Automatic deserialization of Kafka messages (JSON, Avro, and Protocol Buffers)
- Simplified event record handling with intuitive interface
- Support for key and value deserialization
- Support for Standard Schema output parsing (e.g., Zod, Valibot, ArkType)
- Support for Event Source Mapping (ESM) with and without Schema Registry integration
- Out of the box error handling for deserialization issues
Getting Started
To get started, depending on the schema types you want to use, install the library and the corresponding libraries:
- JSON schemas
npm install @aws-lambda-powertools/kafka
- Avro schemas
npm install @aws-lambda-powertools/kafka avro-js
- Protocol Buffer schemas
npm install @aws-lambda-powertools/kafka protobufjs
Additionally, if you want to use output parsing with Standard Schema, you can install any of the supported libraries, for example: Zod, Valibot, or ArkType.
Processing Kafka events
You can use Kafka consumer utility to transform raw Kafka events into an intuitive format for processing.
The kafkaConsumer
function can deserialize both keys and values independently based on your schema configuration. This flexibility allows you to work with different data formats in the same message.
Working with Avro:
Working with Protocol Buffers:
Working with JSON messages
Additional parsing
You can parse deserialized data using your preferred parsing library. This can help you integrate Kafka data with your domain schemas and application architecture, providing type hints, runtime parsing and validation, and advanced data transformations.
The example below uses Zod to create schemas, but you can use any Standard Schema-compatible library:
Error handling
You can handle errors when processing Kafka messages to ensure your application maintains resilience and provides clear diagnostic information.
We lazily decode fields like value
, key
, and headers
only when accessed. This allows you to handle deserialization errors at the point of access rather than when the record is first processed.
To learn more about the launch, read the blog post published alongside the release.
🐛 Bug and hot fixes
- fix(event-handler): fix decorated scope in appsync events (#3974) by @dreamorosi
Changes
- chore(ci): remove some issue & PR automations (#4036) by @dreamorosi
- chore: fix esm scope for layers stack (#4007) by @dreamorosi
🌟New features and non-breaking changes
📜 Documentation updates
- chore(deps): bump urllib3 from 2.2.3 to 2.5.0 in /docs (#4065) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.200.2 to 2.201.0 in the aws-cdk group across 1 directory (#4047) by @dependabot[bot]
- chore(deps): bump tsx from 4.20.2 to 4.20.3 (#4048) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4053) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.149 to 8.10.150 (#4051) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.1 to 24.0.3 (#4050) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.0 to 24.0.1 (#4043) by @dependabot[bot]
- chore(deps): bump tsx from 4.20.1 to 4.20.2 (#4045) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4042) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4041) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4029) by @dependabot[bot]
- chore(deps): bump requests from 2.32.3 to 2.32.4 in /docs (#4031) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.29 to 22.15.30 (#4024) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4021) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4018) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4014) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.200.0 to 2.200.1 in the aws-cdk group across 1 directory (#4015) by @dependabot[bot]
- docs: add bedrock agents page to llmtxt (#4010) by @dreamorosi
🔧 Maintenance
- chore(deps): bump urllib3 from 2.2.3 to 2.5.0 in /docs (#4065) by @dependabot[bot]
- chore(deps-dev): bump zod from 3.25.63 to 3.25.67 (#4055) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.200.2 to 2.201.0 in the aws-cdk group across 1 directory (#4047) by @dependabot[bot]
- chore(deps): bump tsx from 4.20.2 to 4.20.3 (#4048) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4053) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.149 to 8.10.150 (#4051) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 16.1.0 to 16.1.2 (#4052) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.1 to 24.0.3 (#4050) by @dependabot[bot]
- chore(deps-dev): bump zod from 3.25.61 to 3.25.63 (#4044) by @dependabot[bot]
- chore(deps): bump @types/node from 24.0.0 to 24.0.1 (#4043) by @dependabot[bot]
- chore(deps): bump tsx from 4.20.1 to 4.20.2 (#4045) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.28.19 to 3.29.0 (#4046) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4042) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4041) by @dependabot[bot]
- chore(deps): bump brace-expansion (#4039) by @dependabot[bot]
- chore(deps): bump tsx from 4.19.4 to 4.20.1 (#4037) by @dependabot[bot]
- chore(deps-dev): bump zod from 3.25.57 to 3.25.61 (#4038) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#4027) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.30 to 24.0.0 (#4032) by @dependabot[bot]
- chore(deps-dev): bump zod from 3.25.55 to 3.25.56 (#4028) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4029) by @dependabot[bot]
- chore(deps): bump requests from 2.32.3 to 2.32.4 in /docs (#4031) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.29 to 22.15.30 (#4024) by @dependabot[bot]
- chore(deps-dev): bump @redis/client from 5.5.5 to 5.5.6 (#4023) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4021) by @dependabot[bot]
- chore(deps-dev): bump zod from 3.25.51 to 3.25.55 (#4022) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#4018) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#4019) by @[dependabot[bot]](https://...
v2.21.0
Summary
This release introduces a new BedrockAgentFunctionResolver to Event Handler that simplifies connecting AWS Lambda functions to Amazon Bedrock Agents. This feature eliminates the need to write boilerplate code for parsing requests and formatting responses, allowing you to focus on your agent's business logic.
⭐ A big thank you to @VatsalGoel3 and @svozza for their contributions to this release and to Instil for becoming a public customer reference!
Creating Amazon Bedrock Agents
You can now use the new BedrockAgentFunctionResolver
to register tools and handle requests in your Lambda functions. The resolver will automatically parse the request, route it to the appropriate function, and return a well-formed response that includes the tool's output and any existing session attributes.
By default, errors are handled gracefully and returned to the agent with error type and message information, allowing the conversation to continue. This is useful when you want to let the LLM handle errors and reduce boilerplate error-handling code.
If you need more control over error scenarios, you can use BedrockFunctionResponse
to customize the response and determine if the conversation should continue:
You can also use the BedrockFunctionResponse
when you want to enrich the response with session attributes or knowledge base configurations, or when you want the agent to re-prompt the user to provide additional information.
Changes
- chore: fix esm scope for layers stack (#4007) by @dreamorosi
- chore(commons): consolidate boolean parsing (#3970) by @dreamorosi
🌟New features and non-breaking changes
- feat(event-handler): add Amazon Bedrock Agents Functions Resolver (#3957) by @svozza
- feat(commons): environment variable helpers (#3945) by @dreamorosi
📜 Documentation updates
- docs: add bedrock agents page to llmtxt (#4010) by @dreamorosi
- docs(event-handler): add docs page for Bedrock Agent Function (#3991) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4004) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.23 to 22.15.29 (#4001) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4002) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.198.0 to 2.199.0 in the aws-cdk group across 1 directory (#3984) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.21 to 22.15.23 (#3985) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.4 to 0.25.5 (#3980) by @dependabot[bot]
- chore: add Instil as customer reference (#3978) by @dreamorosi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3975) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.197.0 to 2.198.0 in the aws-cdk group across 1 directory (#3968) by @dependabot[bot]
- chore: add latest to site_url (#3966) by @hjgraca
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3965) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3954) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.19 to 22.15.21 (#3956) by @dependabot[bot]
- docs: clarify zod version support (#3961) by @dreamorosi
- chore: Add llms.txt to documentation (#3953) by @hjgraca
🐛 Bug and hot fixes
- fix(parameters): preserve original stack trace on transform failures … (#3982) by @VatsalGoel3
🔧 Maintenance
- docs(event-handler): add docs page for Bedrock Agent Function (#3991) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#4004) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 16.0.0 to 16.1.0 (#3994) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.23 to 22.15.29 (#4001) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#4002) by @dependabot[bot]
- chore(deps): bump ossf/scorecard-action from 2.4.1 to 2.4.2 (#4003) by @dependabot[bot]
- chore(deps-dev): bump zod from 3.25.32 to 3.25.48 (#4000) by @dependabot[bot]
- chore(deps): bump vscode/devcontainers/javascript-node from
1ab856e
to0d29e5f
in /.devcontainer (#3996) by @dependabot[bot] - chore(deps-dev): bump @redis/client from 5.1.0 to 5.1.1 (#3986) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.198.0 to 2.199.0 in the aws-cdk group across 1 directory (#3984) by @dependabot[bot]
- chore(event-handler): align implementation with other runtimes (#3989) by @dreamorosi
- chore(deps-dev): bump typedoc from 0.28.4 to 0.28.5 in the typescript group across 1 directory (#3979) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.21 to 22.15.23 (#3985) by @dependabot[bot]
- chore(deps-dev): bump zod from 3.25.28 to 3.25.32 (#3987) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.4 to 0.25.5 (#3980) by @dependabot[bot]
- chore: add Instil as customer reference (#3978) by @dreamorosi
- chore(deps-dev): bump zod from 3.25.23 to 3.25.28 (#3976) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3975) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.197.0 to 2.198.0 in the aws-cdk group across 1 directory (#3968) by @dependabot[bot]
- feat(event-handler): add Amazon Bedrock Agents Functions Resolver (#3957) by @svozza
- chore(deps-dev): bump zod from 3.25.7 to 3.25.23 (#3969) by @dependabot[bot]
- chore: switch codebase to default esm (#3959) by @dreamorosi
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3965) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#3947) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3954) by @dependabot[bot]
- chore(deps-dev): bump @redis/client from 5.0.1 to 5.1.0 (#3949) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.19 to 22.15.21 (#3956) by @dependabot[bot]
- feat(commons): environment variable helpers (#3945) by @dreamorosi
- chore(deps-dev): bump zod from 3.24.4 to 3.25.7 (#3948) by @dependabot[bot]
This release was made possible by the following contributors:
@VatsalGoel3, @dreamorosi, @hjgraca, and @svozza
v2.20.0
Summary
This release enhances Idempotency to support Valkey- and Redis OSS-compatible databases as a persistence layer. We’ve also added new schemas for AppSync Events APIs and updated existing ones for Amazon DynamoDB and Amazon Kinesis streams.
⭐ A big thank you to @arnabrahman for working on the Idempotency feature, and @kiitosu for their contributions!
Using cache databases with Idempotency
You can now use Valkey- and Redis OSS-compatible databases as a persistence layer for your applications with the Idempotency utility. This allows you to leverage managed services like ElastiCache Serverless, which can scale to hundreds of millions of operations per second with microsecond latency.
To get started, install the latest version of Idempotency along with a cache client:
npm i @aws-lambda-powertools/idempotency @valkey/valkey-glide
Configure the client and pass it to the new CachePersistenceLayer
class:
Pass the new persistence layer to any of the Idempotency methods, for example:
If you are currently using Idempotency with Amazon DynamoDB, you can use the new CachePersistenceLayer
as a drop-in replacement in your functions.
New and Improved Parser Schemas
We’ve added two new schemas for AppSync Events APIs and updated two existing ones for Amazon DynamoDB and Amazon Kinesis streams:
Schema Name | Description |
---|---|
🆕 AppSyncEventsPublishSchema |
New schema to parse PUBLISH operation |
🆕 AppSyncEventsSubscribeSchema |
New schema to parse SUBSCRIBE operation |
DynamoDBStreamSchema |
Added window , state , isFinalInvokeForWindow , isWindowTerminatedEarly , and eventSourceArn fields |
KinesisDataStreamSchema |
Added window , state , isFinalInvokeForWindow , isWindowTerminatedEarly , and eventSourceArn fields |
Changes
🌟New features and non-breaking changes
- feat(parser): add support for tumbling windows in Kinesis and DynamoDB events (#3931) by @kiitosu
- feat(idempotency): support for
Redis
as idempotency backend (#3896) by @arnabrahman - feat(parser): add schemas for AppSync Events (#3907) by @dreamorosi
🌟 Minor Changes
- refactor(event-handler): mark identity field as unknown in event (#3922) by @dreamorosi
📜 Documentation updates
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3939) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.18 to 22.15.19 (#3941) by @dependabot[bot]
- docs(idempotency): add idempotency doc for
CachePersistenceLayer
(#3937) by @arnabrahman - chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3935) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3932) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#3929) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.17 to 22.15.18 (#3930) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
f6c81d5
toeb04b60
in /docs (#3927) by @dependabot[bot] - chore(deps): bump mkdocs-material from 9.6.13 to 9.6.14 in /docs (#3926) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3925) by @dependabot[bot]
- docs(event-handler): add examples on how to drop messages (#3924) by @dreamorosi
- chore(deps-dev): bump markdownlint-cli2 from 0.17.2 to 0.18.0 (#3917) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
95f2ff4
tof6c81d5
in /docs (#3919) by @dependabot[bot] - chore(deps): bump mkdocs-material from 9.6.12 to 9.6.13 in /docs (#3918) by @dependabot[bot]
- feat(parser): add schemas for AppSync Events (#3907) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3909) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3911) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.16 to 22.15.17 (#3912) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.14 to 22.15.16 (#3910) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3904) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.12 to 22.15.14 (#3905) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.3 to 22.15.12 (#3899) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3898) by @dependabot[bot]
- chore(deps): bump esbuild from 0.25.3 to 0.25.4 (#3900) by @dependabot[bot]
🔧 Maintenance
- chore(deps): bump zgosalvez/github-actions-ensure-sha-pinned-actions from 3.0.24 to 3.0.25 (#3942) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3939) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.18 to 22.15.19 (#3941) by @dependabot[bot]
- docs(idempotency): add idempotency doc for
CachePersistenceLayer
(#3937) by @arnabrahman - chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3935) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.28.17 to 3.28.18 (#3936) by @dependabot[bot]
- chore(deps): bump aws-actions/configure-aws-credentials from 4.2.0 to 4.2.1 (#3934) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3932) by @dependabot[bot]
- chore(deps-dev): bump markdownlint-cli2 from 0.18.0 to 0.18.1 (#3933) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#3929) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.17 to 22.15.18 (#3930) by @dependabot[bot]
- chore(deps): bump actions/dependency-review-action from 4.7.0 to 4.7.1 (#3928) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
f6c81d5
toeb04b60
in /docs (#3927) by @dependabot[bot] - chore(deps): bump mkdocs-material from 9.6.13 to 9.6.14 in /docs (#3926) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3925) by @dependabot[bot]
- chore(deps-dev): bump markdownlint-cli2 from 0.17.2 to 0.18.0 (#3917) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
95f2ff4
tof6c81d5
in /docs (#3919) by @dependabot[bot] - chore(deps): bump mkdocs-material from 9.6.12 to 9.6.13 in /docs (#3918) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 15.5.2 to 16.0.0 (#3916) by @dependabot[bot]
- feat(idempotency): support for
Redis
as idempotency backend (#3896) by @arnabrahman - chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3909) by @dependabot[bot]
- chore(deps): bump actions/setup-go from 5.4.0 to 5.5.0 (#3908) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3911) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.16 to 22.15.17 (#3912) by @dependabot[bot]
- chore(deps): bump actions/dependency-review-action from 4.6.0 to 4.7.0 (#3913) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.14 to 22.15.16 (#3910) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3904) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.12 to 22.15.14 (#3905) by @dependabot[bot]
- chore(deps): bump aws-actions/configure-aws-credentials from 4.1.0 to 4.2.0 (#3903) by @dependabot[bot]
- chore(deps): bump vscode/devcontainers/javascript-node from
ee45bc4
to1ab856e
in /.devcontainer (#3902) by @dependabot[bot] - chor...
v2.19.1
Summary
In this release we’ve enhanced Logger to format error stack traces for easier reading in non-production environments.
We also fixed a bug in the Event Handler AppSyncEventResolver
that caused subscription events to be rejected incorrectly. The fix requires no changes on your part besides updating to the latest version.
⭐ A big thank you to Ours Privacy for becoming a public customer reference, and @ConnorKirk for their contributions!
Changes
Pretty print stack trace in dev mode
You can now pretty print error stack traces when dev mode is enabled via the POWERTOOLS_DEV
environment variable. This makes it easier to troubleshoot issues during development.
🌟 Minor Changes
- improv(logger): Format the stack trace as an array of strings in dev mode (#3852) by @ConnorKirk
📜 Documentation updates
- chore: update script to increment govcloud layer in docs (#3889) by @dreamorosi
- chore(deps): bump aws-cdk-lib from 2.193.0 to 2.194.0 in the aws-cdk group across 1 directory (#3887) by @dependabot[bot]
- chore(docs): fix youtube iframes (#3882) by @dreamorosi
- chore(docs): add powertools community mcp (#3876) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3874) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3873) by @dependabot[bot]
- chore(deps): bump tsx from 4.19.3 to 4.19.4 (#3870) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3867) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.2 to 22.15.3 (#3868) by @dependabot[bot]
- chore: add customer reference (#3869) by @dreamorosi
- chore: update snippets & event-handler docs (#3864) by @dreamorosi
- chore(deps): bump esbuild from 0.25.2 to 0.25.3 (#3850) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3861) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3849) by @dependabot[bot]
- chore(deps): bump @types/node from 22.14.1 to 22.15.2 (#3862) by @dependabot[bot]
🐛 Bug and hot fixes
- fix(event-handler): ignore return type from onSubscribe handler (#3888) by @dreamorosi
🔧 Maintenance
- chore: update script to increment govcloud layer in docs (#3889) by @dreamorosi
- chore(deps): bump aws-cdk-lib from 2.193.0 to 2.194.0 in the aws-cdk group across 1 directory (#3887) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.28.16 to 3.28.17 (#3886) by @dependabot[bot]
- chore: pin version of commons dependency (#3880) by @dreamorosi
- chore: remove typedoc zod plugin (#3878) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3874) by @dependabot[bot]
- chore(deps): bump vite from 6.3.2 to 6.3.4 (#3875) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3873) by @dependabot[bot]
- chore: restore typeVersions for old ts config (#3872) by @dreamorosi
- chore(deps): bump tsx from 4.19.3 to 4.19.4 (#3870) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3867) by @dependabot[bot]
- chore(deps): bump @types/node from 22.15.2 to 22.15.3 (#3868) by @dependabot[bot]
- chore: add customer reference (#3869) by @dreamorosi
- chore: update snippets & event-handler docs (#3864) by @dreamorosi
- chore(deps): bump esbuild from 0.25.2 to 0.25.3 (#3850) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.28.15 to 3.28.16 (#3851) by @dependabot[bot]
- chore(deps): bump actions/setup-python from 5.5.0 to 5.6.0 (#3856) by @dependabot[bot]
- chore(deps): bump actions/download-artifact from 4.2.1 to 4.3.0 (#3860) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3861) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3849) by @dependabot[bot]
- chore(deps): bump @types/node from 22.14.1 to 22.15.2 (#3862) by @dependabot[bot]
This release was made possible by the following contributors:
v2.19.0
Summary
We are excited to announce a new integration for Event Handler to work with AWS AppSync Events APIs. This utility provides a structured way to handle AppSync real-time events through dedicated handler methods, automatic routing, and flexible configuration options.
We have also improved the experience for customers who are using the log buffering feature in Logger with AWS Lambda’s Advanced Logging Controls (ALC) enabled by emitting a log when the ALC log level is less verbose than the log level in the buffering configuration, which prevents data loss.
⭐ A big thank you to @jorovipe97 and @ConnorKirk for their contributions to this release!
New Event Handler for AppSync Events
The new AppSyncEventsResolver
is designed to streamline working with AWS AppSync real-time APIs by:
- Handling publish and subscribe events with dedicated handler methods
- Routing events automatically based on namespace and channel patterns
- Supporting wildcard patterns for catch-all handlers
- Controlling event aggregation for batch processing
- Implementing graceful error handling
Handling publish events
You can register handlers for publish events using the onPublish method and specifying a pattern for the namespace and channels. This is useful when you want to modify payload content, persist the message in a database, or apply business logic and conditionally filter messages out.
Handling subscribe events
You can use the onSubscribe() method to process subscription requests before allowing clients to connect to specific channels. This enables authorization checks and subscription filtering based on client context or payload attributes, as well as subscription tracking, for example:
Working with aggregated processing
You can use the aggregate
parameter when registering an onPublish
handler to process multiple events together as a batch. This is useful when you need to optimize database operations, or want to have full control over how the messages are processed.
AppSyncEventsResolver
FAQs
Q: Can I handle different types of events from the same channel?
A: Yes, you can register different handlers for publish and subscribe events on the same channel.
Q: How does handler precedence work with wildcard patterns?
A: More specific patterns take precedence over wildcards. For example, /default/channel1
will be chosen over /default/
, which will be chosen over /
.
Q: What happens when an exception occurs in my handler?
A: With individual processing (aka aggregate
disabled), the utility catches exceptions and includes them in the response for the specific event while still processing other events. You can also explicitly raise an UnauthorizedException exception to reject the entire request.
Q: Does the order of async event processing matter?
A: No, AppSync Events doesn't guarantee delivery order. As long as each response includes the original event ID, AppSync processes them correctly regardless of order. Because of this, when aggregate
is disabled, we call your handlers all at once.
Q: Can I process multiple events as a batch?
A: Yes, enable aggregate
when registering an onPublish
handler to receive all matching events as a batch. When doing so, you're responsible implementing the logic to process them and return a list of corresponding items.
Changes
- chore: update cdk output dir (#3854) by @dreamorosi
🌟New features and non-breaking changes
- feat(event-handler): AppSync Events resolver (#3858) by @dreamorosi
📜 Documentation updates
- feat(event-handler): AppSync Events resolver (#3858) by @dreamorosi
- docs: Update metrics docs to mention correct POWERTOOLS_METRICS_DISABLED variable name. (#3848) by @jorovipe97
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3838) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from sha256:23b69789b1dd836c53ea25b32f62ef8e1a23366037acd07c90959a219fd1f285 to sha256:95f2ff42251979c043d6cb5b1c82e6ae8189e57e02105813dd1ce124021a418b in /docs (#3840) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.11 to 9.6.12 in /docs (#3842) by @dependabot[bot]
- chore(deps): bump @aws-sdk/lib-dynamodb from 3.788.0 to 3.789.0 in the aws-sdk-v3 group across 1 directory (#3835) by @dependabot[bot]
- docs: fix copy-me button (#3836) by @dreamorosi
- docs: add getting started section (#3818) by @dreamorosi
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#3833) by @dependabot[bot]
- chore(deps): bump @types/node from 22.14.0 to 22.14.1 (#3831) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3826) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.148 to 8.10.149 (#3824) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.188.0 to 2.189.0 (#3820) by @dependabot[bot]
- chore(deps): bump the typescript group across 1 directory with 2 updates (#3810) by @dependabot[bot]
🐛 Bug and hot fixes
- fix(parser): Make Kafka key property optional (#3855) by @ConnorKirk
- fix(logger): warn customers when the ALC log level is less verbose than log buffer (#3834) by @ConnorKirk
- fix(logger): warn only once on ALC log level mismatch (#3816) by @dreamorosi
🔧 Maintenance
- feat(event-handler): AppSync Events resolver (#3858) by @dreamorosi
- chore(deps-dev): bump typedoc from 0.28.2 to 0.28.3 in the typescript group across 1 directory (#3844) by @dependabot[bot]
- chore(deps-dev): bump the vitest group across 1 directory with 2 updates (#3845) by @dependabot[bot]
- chore(deps-dev): bump zod from 3.24.2 to 3.24.3 (#3839) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 3 updates (#3838) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from sha256:23b69789b1dd836c53ea25b32f62ef8e1a23366037acd07c90959a219fd1f285 to sha256:95f2ff42251979c043d6cb5b1c82e6ae8189e57e02105813dd1ce124021a418b in /docs (#3840) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.6.11 to 9.6.12 in /docs (#3842) by @dependabot[bot]
- chore(deps): bump @aws-sdk/lib-dynamodb from 3.788.0 to 3.789.0 in the aws-sdk-v3 group across 1 directory (#3835) by @dependabot[bot]
- chore(deps): bump the aws-cdk group across 1 directory with 2 updates (#3833) by @dependabot[bot]
- chore(deps-dev): bump typedoc-plugin-zod from 1.4.0 to 1.4.1 in the typescript group across 1 directory (#3829) by @dependabot[bot]
- chore(deps-dev): bump lint-staged from 15.5.0 to 15.5.1 (#3830) by @dependabot[bot]
- chore(deps): bump @types/node from 22.14.0 to 22.14.1 (#3831) by @dependabot[bot]
- chore(deps): bump actions/setup-node from 4.3.0 to 4.4.0 (#3828) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.28.14 to 3.28.15 (#3817) by @dependabot[bot]
- chore(deps): bump the aws-sdk-v3 group across 1 directory with 9 updates (#3826) by @dependabot[bot]
- chore(deps): bump @types/aws-lambda from 8.10.148 to 8.10.149 (#3824) by @dependabot[bot]
- chore(deps): bump vite from 6.2.5 to 6.2.6 (#3827) by @dependabot[bot]
- chore(deps): bump aws-cdk-lib from 2.188.0 to 2.189.0 (#3820) by @dependabot[bot]
- chore(deps): bump vscode/devcontainers/javascript-node from
be11ae6
toee45bc4
in /.devcontainer (#3819) by @dependabot[bot] - chore(deps): bump the typescript group across 1 directory with 2 updates (#3810) by @dependabot[bot]
- chore(deps): bump github/codeql-action from 3.28.13 to 3.28.14 (#3811) by @dependabot[bot]
- chore(deps): bump vscode/devcontainers/javascript-node from
78fda8c
tobe11ae6
in /.devcontainer (#3812) by @dependabot[bot]
This release was made possible by the following contributors:
@ConnorKirk, @dependabot[bot], @dreamorosi, @github-actions[bot], @jorovipe97, dependabot[bot] and github-actions[bot]