Aws Lambda Powertools Typescript Versions Save

Powertools is a developer toolkit to implement Serverless best practices and increase developer velocity.

v2.1.0

3 weeks ago

Summary

This release marks the first beta release of the new Parser utility πŸŽ‰ and adds custom JMESPath functions to the Idempotency utility.

Parser

⚠️ WARNING: Do not use this utility in production just yet! ⚠️
This AWS Lambda Powertools for TypeScript utility is currently released as beta developer preview and is intended strictly for feedback and testing purposes only. This version is not stable, and significant breaking changes might incur before the GA release.

We are excited to announce the first public beta for the Parser utility, which brings data validation and parsing using Zod, a TypeScript-first schema declaration library.

Key features

To get started install the utility together with Zod 3.x:

npm i @aws-lambda-powertools/parser zod@~3

Next, define your schema that models your event, for example:

import { z } from 'zod';

const orderSchema = z.object({
  id: z.number().positive(),
  description: z.string(),
  items: z.array(
    z.object({
      id: z.number().positive(),
      quantity: z.number(),
      description: z.string(),
    })
  ),
  optionalField: z.string().optional(),
});

The utility comes with built-in schemas for many AWS events (API GW, ALB, SQS, SNS, EventBridge, Kafka, Kinesis, and more) that you can use or extended with your own payloads. For example, when working with events coming from Amazon EventBridge you can provide a custom schema for the detail field:

import type { Context } from 'aws-lambda';
import type { LambdaInterface } from '@aws-lambda-powertools/commons/types';
import { parser } from '@aws-lambda-powertools/parser';
import { z } from 'zod';
import { EventBridgeSchema } from '@aws-lambda-powertools/parser/schemas';

const orderEventSchema = EventBridgeSchema.extend({
  detail: orderSchema, 
});

type OrderEvent = z.infer<typeof orderEventSchema>;

class Lambda implements LambdaInterface {
  @parser({ schema: orderEventSchema }) 
  public async handler(event: OrderEvent, _context: Context): Promise<void> {
    for (const item of event.detail.items) {
      // process OrderItem
    }
  }
}

const myFunction = new Lambda();
export const handler = myFunction.handler.bind(myFunction);

If you are interested only in your custom part of the payload, the utility provides a collection of built-in envelopes that you can use together your schema.

Using envelopes, the utility will validate and parse the entire event and return only your custom part of the payload within the envelope rather than the entire object:

import { parser } from '@aws-lambda-powertools/parser/middleware';
import { z } from 'zod';
import middy from '@middy/core';
import { EventBridgeEnvelope } from '@aws-lambda-powertools/parser/envelopes';

type Order = z.infer<typeof orderSchema>;

const lambdaHandler = async (
  event: Order
): Promise<void> => {
  for (const item of event.items) {
    // item is parsed as { id: number, quanityt: number, description: string }
  }
};

export const handler = middy(lambdaHandler).use(
  parser({ schema: orderSchema, envelope: EventBridgeEnvelope })
);

You can also use built-in schemas and envelopes manually, without middyjs or decorator:

import type { Context } from 'aws-lambda';
import { z } from 'zod';
import { EventBridgeEnvelope } from '@aws-lambda-powertools/parser/envelopes';
import { EventBridgeSchema } from '@aws-lambda-powertools/parser/schemas';
import type { EventBridgeEvent } from '@aws-lambda-powertools/parser/types';

type Order = z.infer<typeof orderSchema>;

export const handler = async (
  event: EventBridgeEvent,
  _context: Context
): Promise<void> => {
  const parsedEvent = EventBridgeSchema.parse(event); 
  // parsed as event bridge event but detail is still unknown
  const order: Order = EventBridgeEnvelope.parse(event, orderSchema); 
  // parsed as event bridge event and detail as orderSchema
};

As mentioned, the utility is published as a beta and thus its API, schemas, and envelopes might change. We however encourage you to give it a try and provide feedback over the next couple of weeks so that we can hash out any issue before we can consider it production ready.

Idempotency

Starting from this release you can use the custom functions from the JMESPath utility when specifying a JMESPath expression to select the idempotency key from payloads.

This is especially useful when working with events that contain encoded data such as Amazon API Gateway or Amazon SQS among others.

import { makeIdempotent, IdempotencyConfig } from '@aws-lambda-powertools/idempotency';
import { DynamoDBPersistenceLayer } from '@aws-lambda-powertools/idempotency/dynamodb';
import type { APIGatewayProxyEvent } from 'aws-lambda';

const persistenceStore = new DynamoDBPersistenceLayer({
  tableName: 'idempotencyTableName',
});

export const handler = makeIdempotent(async (event: APIGatewayProxyEvent) => {
  // handler code goes here
}, {
  persistenceStore,
  config: new IdempotencyConfig({
    eventKeyJmespath: 'powertools_json(body).["user", "productId"]',
  }),
});

The feature is possible thanks to the integration with the @aws-lambda-powertools/jmespath utility that we launched in the previous release and that replaces the existing jmespath library dependency.

Changes

  • chore(deps): bump github/codeql-action from 3.25.0 to 3.25.1 (#2385) by @dependabot
  • chore(ci): fetch entire history for lerna versioning (#2391) by @am29d
  • chore(deps): bump github/codeql-action from 3.24.10 to 3.25.0 (#2363) by @dependabot
  • chore(parser): add DeadLetterQueueSourceArn attribute (#2362) by @am29d

🌟New features and non-breaking changes

  • feat(idempotency): add custom JMESPath functions (#2364) by @dreamorosi
  • docs(parser): add utility readme (#2360) by @dreamorosi

🌟 Minor Changes

  • refactor(jmespath): rename jmespath parsing options type (#2367) by @dreamorosi

πŸ“œ Documentation updates

  • chore(deps-dev): bump aws-sdk from 2.1599.0 to 2.1601.0 (#2393) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2386) by @dependabot
  • test(maintenance): add ESM output to e2e test (#2370) by @dreamorosi
  • chore(deps): bump mkdocs-material from 9.5.17 to 9.5.18 in /docs (#2371) by @dependabot
  • chore(deps): bump squidfunk/mkdocs-material from 6b124e1 to 521644b in /docs (#2373) by @dependabot
  • refactor(jmespath): rename jmespath parsing options type (#2367) by @dreamorosi
  • feat(idempotency): add custom JMESPath functions (#2364) by @dreamorosi
  • chore(deps-dev): bump aws-sdk from 2.1598.0 to 2.1599.0 (#2365) by @dependabot
  • docs(parser): add utility readme (#2360) by @dreamorosi
  • chore(deps): bump the aws-sdk group with 9 updates (#2358) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1597.0 to 2.1598.0 (#2359) by @dependabot
  • chore(deps): bump idna from 3.6 to 3.7 in /docs (#2357) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2354) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1596.0 to 2.1597.0 (#2355) by @dependabot
  • chore(deps): bump typescript from 5.4.4 to 5.4.5 (#2356) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2349) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2350) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1595.0 to 2.1596.0 (#2351) by @dependabot
  • chore(deps): bump @types/node from 20.12.6 to 20.12.7 (#2352) by @dependabot

πŸ› Bug and hot fixes

  • fix(jmespath): refactor custom function introspection to work with minification (#2384) by @dreamorosi

πŸ”§ Maintenance

  • chore(deps-dev): bump aws-sdk from 2.1599.0 to 2.1601.0 (#2393) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2386) by @dependabot
  • chore(parser): add parser to release steps (#2382) by @am29d
  • refactor(jmespath): rename jmespath parsing options type (#2367) by @dreamorosi
  • feat(idempotency): add custom JMESPath functions (#2364) by @dreamorosi
  • chore(deps-dev): bump aws-sdk from 2.1598.0 to 2.1599.0 (#2365) by @dependabot
  • docs(parser): add utility readme (#2360) by @dreamorosi
  • chore(deps): bump the aws-sdk group with 9 updates (#2358) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1597.0 to 2.1598.0 (#2359) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2354) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1596.0 to 2.1597.0 (#2355) by @dependabot
  • chore(deps): bump typescript from 5.4.4 to 5.4.5 (#2356) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2349) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2350) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1595.0 to 2.1596.0 (#2351) by @dependabot
  • chore(deps): bump @types/node from 20.12.6 to 20.12.7 (#2352) by @dependabot

This release was made possible by the following contributors:

@am29d, @dependabot, @dependabot[bot], @dreamorosi, @github-actions and @github-actions[bot]

v2.0.4

4 weeks ago

Summary

This release introduces a new Powertools utility to work with JMESPath, adds the ability to trace requests made via the fetch module for Tracer, and brings bug fixes and improvements for the Logger and Idempotency utilities.

JMESPath

We're excited to release the JMESPath utility, a fully spec compliant high-level library to parse and extract data from JSON objects using JMESPath expressions.

Usage

To get started, install the library by running:

npm i @aws-lambda-powertools/jmespath

At its core, the library provides a utility function to extract data from a JSON object using a JMESPath expression.

import { search } from '@aws-lambda-powertools/jmespath';
import { Logger } from '@aws-lambda-powertools/logger';

const logger = new Logger();

type MyEvent = {
  foo: {
    bar: string;
  };
}

export const handler = async (event: MyEvent): Promise<void> => {
  const result = search(event, 'foo.bar');
  logger.info(result); // "baz"
};

In some cases however, you may want to extract data from an envelope. The library provides a utility function to help you work with envelopes and extract data from them.

import { extractDataFromEnvelope } from '@aws-lambda-powertools/jmespath/envelopes';

type MyEvent = {
  body: string; // "{\"customerId\":\"dd4649e6-2484-4993-acb8-0f9123103394\"}"
  deeplyNested: Array<{ someData: number[] }>;
};

type MessageBody = {
  customerId: string;
};

export const handler = async (event: MyEvent): Promise<unknown> => {
  const payload = extractDataFromEnvelope<MessageBody>(
    event,
    'powertools_json(body)'
  );
  const { customerId } = payload; // now deserialized

  // also works for fetching and flattening deeply nested data
  const someData = extractDataFromEnvelope<number[]>(
    event,
    'deeplyNested[*].someData[]'
  );

  return {
    customerId,
    message: 'success',
    context: someData,
    statusCode: 200,
  };
};

The utility comes with a set of built-in envelopes to help you extract data from common event sources such as S3, SQS, SNS, and more:

import {
  extractDataFromEnvelope,
  SQS,
} from '@aws-lambda-powertools/jmespath/envelopes';
import { Logger } from '@aws-lambda-powertools/logger';
import type { SQSEvent } from 'aws-lambda';

const logger = new Logger();

type MessageBody = {
  customerId: string;
};

export const handler = async (event: SQSEvent): Promise<void> => {
  const records = extractDataFromEnvelope<Array<MessageBody>>(event, SQS);
  for (const record of records) {
    // records is now a list containing the deserialized body of each message
    const { customerId } = record;
    logger.appendKeys({ customerId });
  }
};

Finally, in addition to supporting all the built-in JMESPath functions present in the specification, the utility provides custom functions to help you work with more complex data structures. For example, you can use the powertools_json function to parse a JSON string, or the powertools_base64 function to decode a base64-encoded string:

import { extractDataFromEnvelope } from '@aws-lambda-powertools/jmespath/envelopes';
import { Logger } from '@aws-lambda-powertools/logger';

const logger = new Logger();

export const handler = async (event: { payload: string }): Promise<void> => {
  const data = extractDataFromEnvelope<string>(
    event,
    'powertools_json(powertools_base64(payload))'
  );

  logger.info('Decoded payload', { data });
};

In future releases we will incorporate this utility as part of the Idempotency utility as well as other upcoming utilities.

Tracer

Starting from this release you can trace requests made using the fetch global module that is available in Lambda functions running on managed runtimes Node.js 18 or newer.

The feature is enabled by default and all requests are captured by default. For each request Tracer will generate a subsegment under the currently active segment and annotate it with informations about the request.

For example, the following code:

import { Tracer } from '@aws-lambda-powertools/tracer';
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
import middy from '@middy/core';

const tracer = new Tracer({ serviceName: 'serverlessAirline' });

export const handler = middy(async () => {
  await fetch("http://httpbin.org/status/500");
}).use(captureLambdaHandler(tracer));

Will result in a segments timeline similar to this:

317722392-699f8ad8-3172-41d3-8ab7-58e7786767f6

As you can see, if the request has a 4xx or 5xx like in this case, the appropriate flag is automatically added to the subsegment so you can have complete visibility.

Just like with other requests made using http-based modules before, you can opt out of tracing requests made using fetch by setting either the captureHTTPsRequests constructor parameter or the POWERTOOLS_TRACER_CAPTURE_HTTPS_REQUESTS environment variable to false.

Idempotency

When using the Idempotency utility you can enable in-memory caching so that requests handled by the same Lambda execution environments can be processed without calling the persistence layer.

Prior to this release, some of the requests that caused a "cache hit" would be rejected as if another request was already in progress rather than returning the value from the cache. While this bug could have not caused data loss due to it happening exclusively when retrying an idempotent request, it could have caused an artificially high number of IdempotencyAlreadyInProgess errors.

This release fixes the logic for cache retrieval and ensures that when there's a "cache hit" the correct value is returned from the in-memory cache and its value is returned in the response.

Logger

When initialized the Logger utility performs a number of actions to configure the content of the logs, their format, and its overall behavior. Some of these setup activities can cause warning or debug logs to be emitted if certain conditions are met, for example: if the utility is initialized with a log level that is more verbose than the one set in Lambda's advanced logging controls.

In prior releases of v2 some of these warnings could cause runtime errors to be thrown due to the utility not being fully initialized at the time of emitting the logs. This release brings a new and improved initialization logic that buffers debug and warning logs and emits them only when the Logger instance is ready.

Additionally, the utility now uses template literals instead of the node:util module to format some of these warnings. This change was done to allow the utility to be compatible with LLRT (Low Latency Runtime), an experimental lightweight JavaScript runtime currently under development.

Acknowledgements

Special thanks to @NimmLor, @webdeveric, and @yamatatsu for contributing to this release πŸŽ‰

Changes

  • chore(deps): bump zgosalvez/github-actions-ensure-sha-pinned-actions from 3.0.3 to 3.0.4 (#2343) by @dependabot
  • chore(deps): bump github/codeql-action from 3.24.9 to 3.24.10 (#2331) by @dependabot
  • chore(ci): add monthly roadmap reminder central action (#2330) by @heitorlessa
  • chore(deps): bump actions/setup-python from 5.0.0 to 5.1.0 (#2288) by @dependabot
  • test(jmespath): 100% coverage and spec compliance (#2271) by @dreamorosi
  • chore(deps): bump actions/dependency-review-action from 4.2.4 to 4.2.5 (#2279) by @dependabot
  • chore(deps): bump actions/dependency-review-action from 4.2.3 to 4.2.4 (#2272) by @dependabot
  • chore(deps): bump github/codeql-action from 3.24.8 to 3.24.9 (#2267) by @dependabot
  • chore(deps): bump actions/dependency-review-action from 4.1.3 to 4.2.3 (#2260) by @dependabot
  • chore(deps): bump github/codeql-action from 3.24.7 to 3.24.8 (#2256) by @dependabot

🌟New features and non-breaking changes

  • feat(tracer): instrument fetch requests (#2293) by @dreamorosi
  • feat(jmespath): add parser component (#2266) by @dreamorosi
  • feat(jmespath): add tree interpreter (#2265) by @dreamorosi
  • feat(jmespath): add powertools functions (#2264) by @dreamorosi
  • feat(jmespath): add built in functions (#2259) by @dreamorosi
  • feat(jmespath): add lexer component (#2214) by @dreamorosi
  • feat(jmespath): add abstract syntax tree definition (#2213) by @dreamorosi
  • feat(jmespath): add Expression and utils (#2212) by @dreamorosi

🌟 Minor Changes

  • refactor(logger): use template literal instead of node:util format (#2283) by @NimmLor

πŸ“œ Documentation updates

  • chore(deps): bump @types/node from 20.12.5 to 20.12.6 (#2342) by @dependabot
  • chore(maintenance): update release flow diagram (#2322) by @dreamorosi
  • chore(docs): streamline docs homepage (#2328) by @dreamorosi
  • chore(deps-dev): bump aws-sdk from 2.1593.0 to 2.1595.0 (#2338) by @dependabot
  • chore(deps): bump @types/node from 20.12.4 to 20.12.5 (#2334) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2332) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2324) by @dependabot
  • chore(deps): bump @types/aws-lambda from 8.10.136 to 8.10.137 (#2325) by @dependabot
  • chore(deps): bump typescript from 5.4.3 to 5.4.4 (#2326) by @dependabot
  • chore(docs): update batch docs highlight & links (#2320) by @dreamorosi
  • chore(maintenance): document process to add a new region to layers (#2323) by @dreamorosi
  • feat(tracer): instrument fetch requests (#2293) by @dreamorosi
  • chore(deps-dev): bump aws-sdk from 2.1591.0 to 2.1593.0 (#2321) by @dependabot
  • chore(deps-dev): bump tsx from 4.7.1 to 4.7.2 (#2315) by @dependabot
  • chore(deps): bump @types/node from 20.12.3 to 20.12.4 (#2314) by @dependabot
  • chore(deps): bump @types/node from 20.12.2 to 20.12.3 (#2310) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1589.0 to 2.1591.0 (#2308) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2305) by @dependabot
  • chore(deps): bump squidfunk/mkdocs-material from 065f3af to 6b124e1 in /docs (#2303) by @dependabot
  • chore(deps): bump mkdocs-material from 9.5.16 to 9.5.17 in /docs (#2302) by @dependabot
  • chore(maintenance): make jmespath utility public (#2289) by @dreamorosi
  • chore(docs): fix middy v4 version support (#2301) by @am29d
  • chore(deps): bump mkdocs-material from 9.5.15 to 9.5.16 in /docs (#2299) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1588.0 to 2.1589.0 (#2296) by @dependabot
  • chore(deps): bump squidfunk/mkdocs-material from 3307665 to 065f3af in /docs (#2295) by @dependabot
  • chore(deps): bump @types/node from 20.11.30 to 20.12.2 (#2297) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1587.0 to 2.1588.0 (#2294) by @dependabot
  • chore(deps-dev): bump the aws-sdk group with 1 update (#2291) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1586.0 to 2.1587.0 (#2292) by @dependabot
  • chore(deps): bump @types/node from 20.11.28 to 20.11.30 (#2280) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1583.0 to 2.1586.0 (#2287) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2286) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2275) by @dependabot
  • docs(maintenance): update examples to v2 (#2242) by @dreamorosi
  • chore(deps): bump mkdocs-material from 9.5.14 to 9.5.15 in /docs (#2274) by @dependabot
  • chore(deps): bump squidfunk/mkdocs-material from 6c81a89 to 3307665 in /docs (#2273) by @dependabot
  • docs(jmespath): add utility docs (#2187) by @dreamorosi
  • chore(deps-dev): bump aws-sdk from 2.1582.0 to 2.1583.0 (#2268) by @dependabot
  • chore(deps-dev): bump the aws-sdk group with 3 updates (#2261) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1581.0 to 2.1582.0 (#2263) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1580.0 to 2.1581.0 (#2258) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1579.0 to 2.1580.0 (#2255) by @dependabot
  • chore(deps): bump the aws-sdk group with 11 updates (#2252) by @dependabot
  • chore(deps-dev): bump axios from 1.6.7 to 1.6.8 (#2250) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1578.0 to 2.1579.0 (#2251) by @dependabot
  • chore(deps): bump mkdocs-material from 9.5.13 to 9.5.14 in /docs (#2245) by @dependabot
  • chore(deps): bump squidfunk/mkdocs-material from 3678304 to 6c81a89 in /docs (#2248) by @dependabot

πŸ› Bug and hot fixes

  • fix(idempotency): return correct value from in-memory cache (#2311) by @dreamorosi
  • fix(logger): buffer logs emitted during init (#2277) by @dreamorosi

πŸ”§ Maintenance

  • chore(deps): bump @types/node from 20.12.5 to 20.12.6 (#2342) by @dependabot
  • chore(maintenance): update release flow diagram (#2322) by @dreamorosi
  • chore(deps-dev): bump typedoc from 0.25.12 to 0.25.13 (#2333) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1593.0 to 2.1595.0 (#2338) by @dependabot
  • chore(deps): bump @types/node from 20.12.4 to 20.12.5 (#2334) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2332) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2324) by @dependabot
  • chore(deps): bump @types/aws-lambda from 8.10.136 to 8.10.137 (#2325) by @dependabot
  • chore(deps): bump typescript from 5.4.3 to 5.4.4 (#2326) by @dependabot
  • chore(docs): update batch docs highlight & links (#2320) by @dreamorosi
  • chore(maintenance): document process to add a new region to layers (#2323) by @dreamorosi
  • chore(deps-dev): bump aws-sdk from 2.1591.0 to 2.1593.0 (#2321) by @dependabot
  • chore(deps): bump vscode/devcontainers/javascript-node from 4dbf8b6 to ec1e123 in /.devcontainer (#2318) by @dependabot
  • chore(deps-dev): bump tsx from 4.7.1 to 4.7.2 (#2315) by @dependabot
  • chore(deps): bump the aws-sdk group with 1 update (#2313) by @dependabot
  • chore(deps): bump @types/node from 20.12.3 to 20.12.4 (#2314) by @dependabot
  • chore(deps): bump @types/node from 20.12.2 to 20.12.3 (#2310) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1589.0 to 2.1591.0 (#2308) by @dependabot
  • chore(deps-dev): bump the aws-sdk group with 1 update (#2304) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2305) by @dependabot
  • chore(maintenance): make jmespath utility public (#2289) by @dreamorosi
  • chore(deps-dev): bump aws-sdk from 2.1588.0 to 2.1589.0 (#2296) by @dependabot
  • chore(deps): bump @types/node from 20.11.30 to 20.12.2 (#2297) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1587.0 to 2.1588.0 (#2294) by @dependabot
  • chore(deps-dev): bump the aws-sdk group with 1 update (#2291) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1586.0 to 2.1587.0 (#2292) by @dependabot
  • chore(deps): bump aws-xray-sdk-core from 3.5.4 to 3.6.0 (#2282) by @dependabot
  • chore(deps): bump @types/node from 20.11.28 to 20.11.30 (#2280) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1583.0 to 2.1586.0 (#2287) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2286) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2275) by @dependabot
  • chore(maintenance): adjust type exports in parameters & idempotency (#2285) by @dreamorosi
  • chore(deps): replace deprecated lib to alternative (#2247) by @yamatatsu
  • chore(deps-dev): bump aws-sdk from 2.1582.0 to 2.1583.0 (#2268) by @dependabot
  • chore(deps-dev): bump the aws-sdk group with 3 updates (#2261) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1581.0 to 2.1582.0 (#2263) by @dependabot
  • chore(deps-dev): bump typescript from 5.4.2 to 5.4.3 (#2262) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1580.0 to 2.1581.0 (#2258) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.28 to 20.11.30 (#2253) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1579.0 to 2.1580.0 (#2255) by @dependabot
  • chore(deps): bump the aws-sdk group with 11 updates (#2252) by @dependabot
  • chore(deps-dev): bump axios from 1.6.7 to 1.6.8 (#2250) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1578.0 to 2.1579.0 (#2251) by @dependabot

This release was made possible by the following contributors:

@NimmLor, @am29d, @dreamorosi, @heitorlessa and @yamatatsu

v2.0.3

1 month ago

Summary

This release brings a couple of bug fixes related to our new ESM builds as well as minor improvements in how Logger formats error stack traces.

Idempotency

Due to a misconfiguration in our build process some components of the Idempotency utility were not being transformed correctly when bundling our TypeScript source code to ESM-formatted JavaScript. This caused runtime errors when importing the ESM build of the utility.

With this release we have fixed the build process and resolved the issue so that the Idempotency utility can now be used with functions using ESM.

Layers

Since the v2 release we have started including ESM builds to our public Lambda Layers, however we failed to include a polyfill for the require keyword

Based on our tests the presence of this polyfill should not impact your code but only code paths evaluated as a result of importing Powertools utilities from the layer itself. If you encounter issues with this change please let us know by opening an issue.

Logger

As part of this release have improved the regular expression used to extract the file and line locations of an error from its stack trace. The change didn't result in any chance in the way errors are formatted, so you should not see any difference in your logs.

Acknowledgements

Special thanks to @karthikeyanjp and @miguel-martinr for their contributions as well as @AllyMurray for reporting the issue with bundling.

Changes

  • chore(deps): bump github/codeql-action from 3.24.6 to 3.24.7 (#2220) by @dependabot
  • chore(deps): bump actions/checkout from 4.1.1 to 4.1.2 (#2215) by @dependabot
  • chore(docs): remove missing README from typedoc for jmespath temporarily (#2200) by @am29d
  • chore(deps): bump actions/download-artifact from 4.1.3 to 4.1.4 (#2157) by @dependabot

🌟New features and non-breaking changes

  • feat(logger): improve regex in stack trace parsing (#2194) by @karthikeyanjp
  • feat(commons): add fromBase64 helper function (#2190) by @dreamorosi
  • feat(jmespath): add base types and errors (#2192) by @dreamorosi

🌟 Minor Changes

  • improv(commons): expand type utils functions (#2189) by @dreamorosi

πŸ“œ Documentation updates

  • chore(deps): bump the aws-sdk group with 2 updates (#2237) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1576.0 to 2.1578.0 (#2236) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2227) by @dependabot
  • docs(maintenance): update v1 and v2 status (#2226) by @dreamorosi
  • chore(deps-dev): bump aws-sdk from 2.1575.0 to 2.1576.0 (#2222) by @dependabot
  • chore(deps-dev): bump the aws-sdk group with 1 update (#2221) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1574.0 to 2.1575.0 (#2219) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1568.0 to 2.1574.0 (#2201) by @dependabot
  • chore(deps): bump the aws-sdk group with 10 updates (#2180) by @dependabot
  • chore(docs): fix typo in tracer.md (#2178) by @miguel-martinr
  • chore(docs): add ContextExamples to upgrade guide (#2197) by @am29d
  • chore(deps-dev): bump the aws-sdk group with 3 updates (#2172) by @dependabot
  • chore(deps): bump mkdocs-material from 9.5.12 to 9.5.13 in /docs (#2171) by @dependabot
  • chore(deps): bump mkdocs-material from 9.5.11 to 9.5.12 in /docs (#2153) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2154) by @dependabot
  • chore(deps): bump squidfunk/mkdocs-material from 7be068b to 3678304 in /docs (#2169) by @dependabot

πŸ› Bug and hot fixes

  • fix(layers): add createRequire banner in esm (#2232) by @dreamorosi
  • fix(idempotency): transform private class fields (#2233) by @dreamorosi

πŸ”§ Maintenance

  • chore(deps): bump the aws-cdk group with 2 updates (#2238) by @dependabot
  • chore(deps): bump the aws-sdk group with 2 updates (#2237) by @dependabot
  • chore(deps): bump esbuild from 0.20.1 to 0.20.2 (#2239) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1576.0 to 2.1578.0 (#2236) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.26 to 20.11.28 (#2235) by @dependabot
  • chore(deps-dev): bump follow-redirects from 1.15.5 to 1.15.6 (#2234) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2227) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1575.0 to 2.1576.0 (#2222) by @dependabot
  • chore(deps-dev): bump the aws-sdk group with 1 update (#2221) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.25 to 20.11.26 (#2218) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1574.0 to 2.1575.0 (#2219) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2216) by @dependabot
  • improv(commons): expand type utils functions (#2189) by @dreamorosi
  • chore(deps): bump the aws-cdk group with 2 updates (#2202) by @dependabot
  • feat(commons): add fromBase64 helper function (#2190) by @dreamorosi
  • chore(deps-dev): bump typescript from 5.3.3 to 5.4.2 (#2176) by @dependabot
  • chore(deps-dev): bump typedoc from 0.25.11 to 0.25.12 (#2203) by @dependabot
  • chore(deps): bump aws-xray-sdk-core from 3.5.3 to 3.5.4 (#2183) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1568.0 to 2.1574.0 (#2201) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.24 to 20.11.25 (#2182) by @dependabot
  • chore(deps): bump the aws-sdk group with 10 updates (#2180) by @dependabot
  • chore(jmespath): add package to workspace (#2185) by @dreamorosi
  • chore(deps-dev): bump @types/aws-lambda from 8.10.134 to 8.10.136 (#2175) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2173) by @dependabot
  • chore(deps-dev): bump the aws-sdk group with 3 updates (#2172) by @dependabot
  • chore(deps-dev): bump typedoc from 0.25.8 to 0.25.11 (#2174) by @dependabot
  • chore(deps-dev): bump eslint from 8.56.0 to 8.57.0 (#2150) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2154) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.22 to 20.11.24 (#2155) by @dependabot
  • chore(deps): bump vscode/devcontainers/javascript-node from 7a20ece to 4dbf8b6 in /.devcontainer (#2168) by @dependabot

This release was made possible by the following contributors:

@am29d, @dreamorosi, @karthikeyanjp and @miguel-martinr

v2.0.2

2 months ago

Summary

This patch release fixes a bug affecting customers using Tracer in a JavaScript ESM environment.

Tracer

In v2.0.0 we launched ESM support and most of our focus went on customers using Powertools with TypeScript and bundlers (i.e. esbuild). This introduced a bug that prevented customers using plain JavaScript with ESM from successfully importing the utility.

This release changes the way that the AWS X-Ray SDK for Node.js is imported within the Tracer utility so that customers using ESM with JavaScript can import the utility correctly.

Special thanks to @webdeveric for reporting the issue and suggesting a fix.

Changes

πŸ› Bug and hot fixes

  • fix(tracer): modify aws-xray-sdk-core import for js (#2164) by @dreamorosi

This release was made possible by the following contributors:

@dreamorosi

v2.0.1

2 months ago

Summary

This is a patch release we had to make to align the new Lambda Layer ARNs to the v2.0.0 major release.

The ARN for the new major version will use this format: arn:aws:lambda:{region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:1.

You can find a list of changes introduced with v2 in the v2.0.0 release notes.

Changes

  • chore(docs): mark docs/snippets package as private (#2161) by @dreamorosi

This release was made possible by the following contributors:

@dreamorosi, @am29d

v2.0.0

2 months ago

Summary

We are super happy to announce our next major version – v2.0.0 πŸŽ‰πŸŽ‰!

The most requested feature by customers was enabling ESM support. The ecosystem is gradually moving to ESM and today 1 in 5 of the popular packages on npm contains ESM. You can now take advantage of modern features like top-level await, and advanced techniques like tree shaking to benefit from smaller bundles.

Using CommonJS? We have your back! v2 supports both CommonJS and ESM, as we know the ecosystem is in a transition phase as we speak.

The second most requested feature was further Logger customizations. Extending logger to customize log attributes became easier – we now differentiate between standard and custom log attributes. Based on your feedback, we’ve also improved typing and made it more intuitive to decide what the final output should be.

We care deeply about minimizing breaking changes

Over the past few months, we carefully selected each breaking change to make, and crafted an extensive upgrade guide to ease your transition to v2. Please let us know whether we can make your upgrade process easier.

🌟 We couldn’t have done this without you 🌟

Thanks to everyone in the community for their patience and assistance as we've been working on this release. A special thanks to @antstanley, @erikayao93, and @shdq for their contributions to this milestone.

[!NOTE] The section below is an excerpt of what's available in the Upgrade guide

What’s New in v2

ESM Support

With support for ESM in v2, you can now use import instead of require syntax.

This is especially useful when you want to run asynchronous code during the initialization phase by using top-level await.

import { getSecret } from '@aws-lambda-powertools/parameters/secrets';

// This code will run during the initialization phase of your Lambda function
const myApiKey = await getSecret('my-api-key', { transform: 'json' });

export const handler = async (_event: unknown, _context: unknown) => {
    // ...
};

If you are unable to use ESM, you can still use the require syntax to import packages. We will continue to support it by shipping CommonJS alongside ESM.

When using a dependency or transitive dependency that doesn’t support ESM yet, you can still use ESM and polyfill the import during your bundling step.

For example, Tracer (@aws-lambda-powertools/tracer) relies on the AWS X-Ray SDK for Node.js which uses require.

Here’s an example of how to polyfill the require keyword using AWS CDK and esbuild:

import { Stack, type StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { NodejsFunction, OutputFormat } from 'aws-cdk-lib/aws-lambda-nodejs';
import { Runtime } from 'aws-cdk-lib/aws-lambda';

export class MyStack extends Stack {
  public constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const handler = new NodejsFunction(this, 'helloWorldFunction', {
      runtime: Runtime.NODEJS_20_X,
      handler: 'handler',
      entry: 'src/index.ts',
      bundling: {
        format: OutputFormat.ESM,
        banner: 
          "import { createRequire } from 'module';const require = createRequire(import.meta.url);", 
      },
    });
  }
}

Logger new features

Complete log format customization

In v1, the Logger utility exposed the standard structured keys to custom log formatters as a single argument and expected a plain object with keys and values for the log output:

import { LogFormatter } from '@aws-lambda-powertools/logger';
import {
  LogAttributes,
  UnformattedAttributes,
} from '@aws-lambda-powertools/logger/lib/types';

class MyCompanyLogFormatter extends LogFormatter {
  public formatAttributes(attributes: UnformattedAttributes): LogAttributes {
    return {
      message: attributes.message,
      service: attributes.serviceName,
      environment: attributes.environment,
      awsRegion: attributes.awsRegion,
      correlationIds: {
        awsRequestId: attributes.lambdaContext?.awsRequestId,
        xRayTraceId: attributes.xRayTraceId,
      },
      lambdaFunction: {
        name: attributes.lambdaContext?.functionName,
        arn: attributes.lambdaContext?.invokedFunctionArn,
        memoryLimitInMB: attributes.lambdaContext?.memoryLimitInMB,
        version: attributes.lambdaContext?.functionVersion,
        coldStart: attributes.lambdaContext?.coldStart,
      },
      logLevel: attributes.logLevel,
      timestamp: this.formatTimestamp(attributes.timestamp),
      logger: {
        sampleRateValue: attributes.sampleRateValue,
      },
    };
  }
}

export { MyCompanyLogFormatter };

In v2, you now have complete control over both standard (attributes) and custom keys (additionalLogAttributes) in the formatAttributes() method. Also, you now may return a LogItem object to increase type safety when defining the final log output.

import { LogFormatter, LogItem } from '@aws-lambda-powertools/logger';
import type { LogAttributes, UnformattedAttributes } from '@aws-lambda-powertools/logger/types';

class MyCompanyLogFormatter extends LogFormatter {
  public formatAttributes(
    attributes: UnformattedAttributes,
    additionalLogAttributes: LogAttributes  
  ): LogItem {  
    const baseAttributes = {
        message: attributes.message,
        service: attributes.serviceName,
        environment: attributes.environment,
        awsRegion: attributes.awsRegion,
        correlationIds: {
            awsRequestId: attributes.lambdaContext?.awsRequestId,
            xRayTraceId: attributes.xRayTraceId,
        },
        lambdaFunction: {
            name: attributes.lambdaContext?.functionName,
            arn: attributes.lambdaContext?.invokedFunctionArn,
            memoryLimitInMB: attributes.lambdaContext?.memoryLimitInMB,
            version: attributes.lambdaContext?.functionVersion,
            coldStart: attributes.lambdaContext?.coldStart,
        },
        logLevel: attributes.logLevel,
        timestamp: this.formatTimestamp(attributes.timestamp),
        logger: {
            sampleRateValue: attributes.sampleRateValue,
        },
    };

    // Create a new LogItem with the base attributes
    const logItem = new LogItem({ attributes: baseAttributes });

    // Merge additional attributes
    logItem.addAttributes(additionalLogAttributes); 

    return logItem;
  }
}

export { MyCompanyLogFormatter };

With this change you can tailor the format of your logs to your company’s standards and seamlessly integrate with third-party observability providers that require specific formats. This new modular LogFormatter will also allow us to add more features over the coming releases, so stay tuned!

Log sampling

In v1, log sampling implementation was inconsistent from other Powertools for AWS Lambda languages (Python, .NET, Java).

Logger sampleRateValue continues to determine the percentage of concurrent/cold start invocations that logs will be sampled, e.g. log level set to DEBUG.

However in v2, we changed slightly the implementation for consistency across languages:

Behavior v1 v2
Log Level Log level remains unchanged and any log statement is printed Log level changes to DEBUG
Log sampling indication No indication Debug message emitted during initialization indicates sampling is enabled

Scoped imports

In v2, we improved tree-shaking support to help you reduce your function bundle size. That is, only bundle what you use.

To help you import and bundle only code paths that you really need we’ve added support for subpath exports. This means that you can target certain modules based on their path.

For example, in v1 you could import Middy.js middlewares from the default export of a package (e.g. injectLambdaContext would be imported from @aws-lambda-powertools/logger).

import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger';
import { Tracer, captureLambdaHandler } from '@aws-lambda-powertools/tracer';
import { Metrics, logMetrics } from '@aws-lambda-powertools/metrics';

In v2, you can now import only the Middy.js middlewares from a dedicated path. This means if you don’t use Middy.js you will benefit from a smaller bundle size.

import { Logger } from '@aws-lambda-powertools/logger';
import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware';

import { Tracer } from '@aws-lambda-powertools/tracer';
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';

import { Metrics } from '@aws-lambda-powertools/metrics';
import { logMetrics } from '@aws-lambda-powertools/metrics/middleware';

Likewise, in v2 you can now directly import all TypeScript types from a convenient and well-known types subpath export.

-- import { LogAttributes, UnformattedAttributes } from '@aws-lambda-powertools/logger/lib/types';
++ import { LogAttributes, UnformattedAttributes } from '@aws-lambda-powertools/logger/types';

This will standardize types import across packages and future-proof growth.

This change has been rolled out to all types of all packages. We would love to hear your feedback on further improvements we could make in this area.

Backwards incompatible changes

Here’s a quick view of deprecated features removed and backwards incompatible changes:

Area Change Code change required
Middy.js Updated import path for Middy.js middlewares to leverage subpath exports - i.e. @aws-lambda-powertools/logger/middleware Yes
Types imports Updated import path for TypeScript types to leverage subpath exports - i.e. @aws-lambda-powertools/logger/types Yes
Metrics Renamed MetricUnits enum to MetricUnit (singular) for consistency Yes
Logger Updated custom log formatter interface to include standard keys as well as persistent keys Yes
Logger Changed log sampling to dynamically switch log level to DEBUG on a percentage of requests -
Logger and Tracer Removed deprecated createLogger and createTracer helper functions in favor of direct instantiation Yes

Changes

  • chore(deps): bump github/codeql-action from 3.24.5 to 3.24.6 (#2152) by @dependabot
  • chore(deps): bump github/codeql-action from 3.24.0 to 3.24.5 (#2132) by @dependabot
  • chore(deps): bump actions/download-artifact from 4.1.2 to 4.1.3 (#2142) by @dependabot
  • chore(deps): bump actions/dependency-review-action from 4.0.0 to 4.1.3 (#2119) by @dependabot

πŸ“œ Documentation updates

  • chore(deps-dev): bump aws-sdk from 2.1567.0 to 2.1568.0 (#2149) by @dependabot
  • chore(deps): bump squidfunk/mkdocs-material from 62d3668 to 7be068b in /docs (#2148) by @dependabot
  • chore(deps): bump mkdocs-material from 9.5.9 to 9.5.11 in /docs (#2139) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2144) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1557.0 to 2.1567.0 (#2143) by @dependabot
  • feat!: version 2, the ESM update (#2117) by @dreamorosi

πŸ”§ Maintenance

  • chore(deps-dev): bump aws-sdk from 2.1567.0 to 2.1568.0 (#2149) by @dependabot
  • chore(deps-dev): bump @types/aws-lambda from 8.10.133 to 8.10.134 (#2151) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.17 to 20.11.22 (#2147) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2144) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2133) by @dependabot
  • chore(deps): bump esbuild from 0.20.0 to 0.20.1 (#2104) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1557.0 to 2.1567.0 (#2143) by @dependabot
  • chore(maintenance): migrate init script and husky to v9 (#2131) by @hjgraca
  • feat!: version 2, the ESM update (#2117) by @dreamorosi

This release was made possible by the following contributors:

@dreamorosi, @am29d, @hjgraca, @antstanley, @erikayao93, and @shdq

v1.18.1

2 months ago

Summary

This patch release fixes a regression in the Idempotency utility introduced in the previous release that prevented stored records to be validated when validation was enabled. We also have published our versioning and maintenance policy and the upgrade guide to our next major version.

Idempotency

When using the utility, you can use the payloadValidationJmesPath option, to provide a JMESPath expression to specify which part of the event body should be validated against previous idempotent invocations. Due to a bug we introduced in the last release, the validation was not applied when using the recent versions of the AWS SDK.

This release fixes the bug and restores the validation for all requests, regardless of AWS SDK version. Thanks to @kevin-secrist for identifying and reporting the issue!

Announcements

The next major version of Powertools for AWS Lambda (TypeScript) is launching soon. We have prepared an upgrade guide that we hope will help you get ready for the upgrade.

Additionally, we also have made public our versioning and maintenance policy. The document highlights our versioning strategy and we hope will give you more clarity on the project.

🌟New features and non-breaking changes

  • feat(idempotency): return existing record in IdempotencyValidationError (#2059) by @kevin-secrist

πŸ“œ Documentation updates

  • chore(docs): fix broken upgrade guide link in banner (#2091) by @dreamorosi
  • docs(maintenance): create upgrade guide from v1 to v2 (#1994) by @dreamorosi
  • chore(docs): add Alma Media to list of companies using Powertools (#2021) by @am29d
  • docs(maintenance): add versioning and maintenance policy (#1996) by @heitorlessa

πŸ› Bug and hot fixes

  • fix(idempotency): validate idempotency record returned in conditional write (#2083) by @dreamorosi

πŸ”§ Maintenance

  • chore(ci): create one layer artifact per region & merge (#2095) by @dreamorosi
  • chore(ci): bump version to 1.18.1 (#2113) by @dreamorosi
  • chore(maintenance): add core team to code owners (#2099) by @dreamorosi
  • chore(deps): bump the aws-sdk group with 9 updates (#2087) by @dependabot
  • chore(deps-dev): bump husky from 9.0.10 to 9.0.11 (#2069) by @dependabot
  • chore(deps-dev): bump socks & ip-address (#2065) by @dreamorosi
  • chore(deps-dev): bump @types/node from 20.11.16 to 20.11.17 (#2057) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1549.0 to 2.1557.0 (#2063) by @dependabot
  • chore(deps-dev): bump typedoc from 0.25.7 to 0.25.8 (#2056) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2054) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2061) by @dependabot
  • chore(deps-dev): bump lerna from 8.0.2 to 8.1.2 (#2038) by @dependabot
  • chore(deps-dev): bump @typescript-eslint/parser from 6.19.1 to 6.21.0 (#2025) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2037) by @dependabot
  • chore(deps-dev): bump husky from 9.0.6 to 9.0.10 (#2039) by @dependabot
  • chore(deps-dev): bump prettier from 3.2.4 to 3.2.5 (#2040) by @dependabot
  • chore(deps-dev): bump @typescript-eslint/eslint-plugin from 6.19.1 to 6.21.0 (#2024) by @dependabot
  • chore(deps-dev): bump @types/jest from 29.5.11 to 29.5.12 (#2019) by @dependabot
  • chore(deps-dev): bump @types/aws-lambda from 8.10.131 to 8.10.133 (#2018) by @dependabot
  • chore(deps-dev): bump lint-staged from 15.2.0 to 15.2.2 (#2026) by @dependabot
  • chore(deps): bump vscode/devcontainers/javascript-node from ff7fcaf to 7a20ece in /.devcontainer (#2035) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#2011) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.7 to 20.11.16 (#2010) by @dependabot
  • chore(deps): bump esbuild from 0.19.12 to 0.20.0 (#1988) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#2008) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1544.0 to 2.1549.0 (#2009) by @dependabot
  • chore(deps-dev): bump axios from 1.6.6 to 1.6.7 (#1976) by @dependabot
  • chore(deps-dev): bump husky from 9.0.5 to 9.0.6 (#1975) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1543.0 to 2.1544.0 (#1977) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.6 to 20.11.7 (#1974) by @dependabot
  • chore(deps-dev): bump husky from 9.0.3 to 9.0.5 (#1971) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#1972) by @dependabot
  • chore(deps-dev): bump axios from 1.6.5 to 1.6.6 (#1964) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.5 to 20.11.6 (#1963) by @dependabot
  • chore(deps-dev): bump husky from 8.0.3 to 9.0.3 (#1962) by @dependabot

This release was made possible by the following contributors:

@am29d, @dreamorosi, @heitorlessa, @hjgraca, and @kevin-secrist

v1.18.0

3 months ago

Summary

This minor release introduces improvements around how the Idempotency utility handles conditional writes when used with DynamoDB as persistence layer. Additionally the release fixes an issue with expired AppConfig session tokens that affected long lived execution environments.

Idempotency: DynamoDB storage optimization

The Idempotency utility uses conditional writes to persist the idempotency state of a request. A failed conditional write signals to the utility that the request payload being processed has already been tried or is currently being processed.

Previously, condition check errors in single write operations did not return a copy of the item in the event of a condition check error. A separate read request was necessary to get the item and investigate the cause of the error.

Now that AWS introduced the ability to return a copy of the item as it was during the write attempt the Idempotency utility simplifies and lowers the cost of handling retries by removing the need to perform a separate read operation to retrieve the idempotency record of the request already processed.

Note that this feature requires you to use version v3.363.0 of the @aws-sdk/client-dynamodb or newer together with @aws-lambda-powertools/idempotency.

Parameters: AppConfig Session Token handling

When retrieving a configuration from AppConfig the Parameters utility retrieves a session token that can be used to retrieve the next value within 24 hours. Prior to this release the utility mistakenly assumed that the execution environment would be recycled before that time due to the Lambda timeout of 15 minutes.

For those customers who use provisioned concurrency or use the Parameters utility outside of Lambda however this was an issue as it caused the utility to fail retrieving new configurations from AppConfig due to an expired token. Starting from this release the utility keeps track of the token expiration timestamp and retrieves a new one before attempting to call AppConfig if the token has already expired.

Acknowledgements

Congrats to @daschaa, @tolutheo, and @yamatatsu for getting their first PR merged πŸŽ‰

Changes

  • chore(maintenance): add overwrite to artifact arn in layer pipeline (#1970) by @dreamorosi
  • chore(maintenance): group CDK cli with other CDK dependencies (#1968) by @dreamorosi
  • chore(maintenance): add environment scope to npm token (#1957) by @dreamorosi
  • chore(maintenance): fine tune dependabot config (#1935) by @dreamorosi
  • chore(ci): add aws-sdk group and ignore middy upgrades in examples (#1893) by @am29d
  • chore(ci): allow deps-dev for semantic PR (#1861) by @am29d
  • chore(ci): allow dependabot PRs (#1860) by @heitorlessa
  • chore(ci): [StepSecurity] Apply security best practices (#1839) by @step-security-bot
  • chore(internal): broken link in boring-cyborg app (#1807) by @daschaa
  • chore(ci): Update log retention for layers (#1809) by @sthulb
  • chore(ci): Update permissions in workflows (#1810) by @sthulb
  • chore(ci): sets base permissions on all workflows (#1801) by @sthulb

🌟New features and non-breaking changes

  • feat(idempotency): leverage new dynamodB Failed conditional writes behavior (#1779) by @tolutheo

πŸ“œ Documentation updates

  • chore(docs): bump layer version to 28 in docs (#1969) by @am29d
  • chore(docs): add link to performance tuning demo (#1960) by @dreamorosi
  • chore(layers): add ca-west-1 (#1836) by @am29d
  • feat(idempotency): leverage new dynamodB Failed conditional writes behavior (#1779) by @tolutheo
  • docs: fix typos (#1834) by @am29d
  • docs: fix some typos (#1824) by @yamatatsu
  • docs: fix deps and build (#1830) by @am29d
  • chore(maintenance): add --require-hashes flag to pip installs (#1827) by @dreamorosi
  • chore(docs): add AppYourself reference customer (#1826) by @dreamorosi
  • docs(logger): remove logEvent from required settings (#1821) by @am29d
  • chore(docs): fix layer version in CDK example (#1805) by @daschaa

πŸ› Bug and hot fixes

  • fix(parameters): refresh AppConfig session token after 24 hrs (#1916) by @dreamorosi

πŸ”§ Maintenance

  • chore(deps-dev): bump husky from 9.0.3 to 9.0.5 (#1971) by @dependabot
  • chore(deps): bump the aws-cdk group with 2 updates (#1972) by @dependabot
  • chore(deps-dev): bump axios from 1.6.5 to 1.6.6 (#1964) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.5 to 20.11.6 (#1963) by @dependabot
  • chore(deps-dev): bump husky from 8.0.3 to 9.0.3 (#1962) by @dependabot
  • chore(docs): add link to performance tuning demo (#1960) by @dreamorosi
  • chore(deps): bump the aws-sdk group with 9 updates (#1959) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1540.0 to 2.1543.0 (#1958) by @dependabot
  • chore(deps-dev): bump @typescript-eslint/eslint-plugin from 6.19.0 to 6.19.1 (#1948) by @dependabot
  • chore(deps-dev): bump @typescript-eslint/parser from 6.19.0 to 6.19.1 (#1946) by @dependabot
  • chore(deps): bump esbuild from 0.19.11 to 0.19.12 (#1952) by @dependabot
  • chore(deps-dev): bump ts-jest from 29.1.1 to 29.1.2 (#1943) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1538.0 to 2.1540.0 (#1944) by @dependabot
  • chore(deps): bump the aws-sdk group with 9 updates (#1940) by @dependabot
  • chore(deps): bump the aws-cdk group with 1 update (#1936) by @dependabot
  • chore(deps): bump the aws-sdk group with 4 updates (#1937) by @dependabot
  • chore(deps): bump aws-cdk from 2.121.1 to 2.122.0 (#1938) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1537.0 to 2.1538.0 (#1933) by @dependabot
  • chore(deps-dev): bump aws-sdk from 2.1536.0 to 2.1537.0 (#1926) by @dependabot
  • chore(deps-dev): bump prettier from 3.2.2 to 3.2.4 (#1927) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.4 to 20.11.5 (#1928) by @dependabot
  • chore(deps-dev): bump lerna from 7.4.2 to 8.0.2 (#1923) by @dependabot
  • chore(maintenance): fix install command for .devcontainer setup (#1924) by @am29d
  • chore(deps-dev): bump @types/node from 20.11.2 to 20.11.4 (#1920) by @dependabot
  • chore(deps): fix dependencies and dependabot config (#1917) by @dreamorosi
  • chore(deps-dev): bump typedoc-plugin-missing-exports from 2.1.0 to 2.2.0 (#1911) by @dependabot
  • chore(deps-dev): bump @types/lodash.merge from 4.6.7 to 4.6.9 (#1902) by @dependabot
  • chore(deps-dev): bump @types/node from 20.11.0 to 20.11.2 (#1912) by @dependabot
  • chore(deps-dev): bump @types/aws-lambda from 8.10.129 to 8.10.131 (#1901) by @dependabot
  • chore(deps): bump vscode/devcontainers/javascript-node from b01b5db to ff7fcaf in /.devcontainer (#1892) by @dependabot
  • chore(deps-dev): bump aws-sdk-client-mock-jest from 3.0.0 to 3.0.1 (#1897) by @dependabot
  • chore(deps-dev): bump eslint-config-prettier from 9.0.0 to 9.1.0 (#1872) by @dependabot
  • chore(deps-dev): bump @types/node from 20.10.7 to 20.11.0 in /examples/cdk (#1885) by @dependabot
  • chore(deps-dev): bump @types/node from 20.10.7 to 20.11.0 in /examples/sam (#1890) by @dependabot
  • chore(deps-dev): bump @typescript-eslint/parser from 6.12.0 to 6.18.1 (#1896) by @dependabot
  • chore(deps-dev): bump eslint-import-resolver-typescript from 3.6.0 to 3.6.1 (#1874) by @dependabot
  • chore(deps-dev): bump follow-redirects from 1.15.2 to 1.15.4 (#1842) by @dependabot
  • chore(deps): bump esbuild from 0.19.3 to 0.19.11 (#1868) by @dependabot
  • chore(deps-dev): bump typedoc from 0.25.1 to 0.25.7 (#1869) by @dependabot
  • chore(deps): bump vscode/devcontainers/javascript-node from a20adf8 to b01b5db in /.devcontainer (#1840) by @dependabot
  • chore(deps-dev): bump @aws-sdk/client-cloudwatch from 3.438.0 to 3.485.0 (#1857) by @dependabot
  • chore(deps-dev): bump @types/promise-retry from 1.1.3 to 1.1.6 (#1866) by @dependabot
  • chore(ci): Dependabot fine tuning (#1862) by @am29d
  • chore(deps): bump constructs from 10.2.70 to 10.3.0 (#1846) by @dependabot
  • chore(deps-dev): bump @types/node from 20.6.1 to 20.10.7 in /examples/cdk (#1851) by @dependabot
  • chore(deps-dev): bump @types/node from 20.6.1 to 20.10.7 in /examples/sam (#1853) by @dependabot
  • chore(deps): bump aws-cdk from 2.107.0 to 2.118.0 (#1854) by @dependabot
  • chore(deps): bump aws-cdk-lib from 2.107.0 to 2.118.0 (#1856) by @dependabot
  • docs: fix typos (#1834) by @am29d
  • docs: fix some typos (#1824) by @yamatatsu
  • chore(docs): add AppYourself reference customer (#1826) by @dreamorosi

This release was made possible by the following contributors:

@am29d, @daschaa, @dreamorosi, @heitorlessa, @sthulb, @tolutheo, and @yamatatsu

v1.17.0

5 months ago

Summary

Starting from this release Powertools for AWS Lambda (TypeScript) will no longer officially support the Node.js 14 runtime for AWS Lambda.

On November 27, AWS will begin the deprecation process for the Node.js 14 runtime, which means it will not be possible to deploy new functions using this runtime after that date. Given this change by Lambda, we can no longer run integration tests or provide full support for Node.js 14.

The previous version, v1.16.0, will remain the last release that is fully compatible with Node.js 14. Upgrading to v1.17.0 will not change any behavior or API - this release represents only a change in official support for the deprecated Node.js 14 runtime.

We announced plans for ending Node.js 14 support three months ago. We recommend upgrading your Lambda functions to Node.js 18 or later to avoid any disruption.

As always, we welcome your feedback and questions.

Changes

  • chore(ci): Add OSSF Scorecard Workflow (#1797) by @sthulb

πŸ“œ Documentation updates

  • chore(ci): Fix pinned dependencies (#1800) by @sthulb

πŸ”§ Maintenance

  • chore(maintenance): restore .devcontainer (#1803) by @dreamorosi
  • chore(maintenance): drop support for Node.js 14 (#1802) by @dreamorosi
  • chore(ci): Fix pinned dependencies (#1800) by @sthulb

This release was made possible by the following contributors:

@dreamorosi, @sthulb

v1.16.0

5 months ago

Summary

In this minor release we are adding support for two new environments variables to configure the log level in Logger.

You can now configure the log level of for Logger using two new environment variables: AWS_LAMBDA_LOG_LEVEL and POWERTOOLS_LOG_LEVEL. The new environment variables will work along the existing LOG_LEVEL variable that is now considered legacy and will be removed in the future.

Setting the log level now follows this order:

  1. AWS_LAMBDA_LOG_LEVEL environment variable
  2. Setting the log level in code using the logLevel constructor option, or by calling the logger.setLogLevel() method
  3. POWERTOOLS_LOG_LEVEL environment variable

We have also added a new section to the docs to highlight the new behavior.

Changes

🌟New features and non-breaking changes

  • feat(logger): add support for AWS_LAMBDA_LOG_LEVEL and POWERTOOLS_LOG_LEVEL (#1795) by @dreamorosi

πŸ“œ Documentation updates

  • feat(logger): add support for AWS_LAMBDA_LOG_LEVEL and POWERTOOLS_LOG_LEVEL (#1795) by @dreamorosi

This release was made possible by the following contributors:

@dreamorosi