Lambda layers - Powertools for AWS Lambda (TypeScript) (original) (raw)
A Lambda Layer is a .zip file archive that can contain additional code, pre-packaged dependencies, data, or configuration files. We provide a Lambda Layer for Powertools for AWS Lambda (TypeScript) to help you get started quickly with the library.
You can add our layer both in the AWS Lambda Console (under Layers), or via your favorite infrastructure as code framework with the ARN value. You can use the Lambda Layer both with CommonJS and ESM (ECMAScript modules).
Layer ARNs¶
We publish the Lambda Layer for Powertools for AWS Lambda in all commercial regions and AWS GovCloud (US) regions.
Spotted a missing region?
Open an issue in our GitHub repository to request it.
Lookup Layer ARN via AWS SSM Parameter Store¶
You can also use AWS SSM Parameter Store to dynamically add Powertools for AWS Lambda. The {version} placeholder is the semantic version number (e,g. 2.1.0) for a release or _latest_.
For example, to get the ARN for version 2.14.0 in the eu-west-1 region, run the following command:
| AWS CLI command to get Lambda Layer ARN | |
|---|---|
| 1 2 3 4 5 6 7 8 9 10 11 | aws ssm get-parameter --name /aws/service/powertools/typescript/generic/all/2.14.0 --region eu-west-1 # output Parameter: ARN: arn:aws:ssm:eu-west-1::parameter/aws/service/powertools/typescript/generic/all/2.14.0 DataType: text LastModifiedDate: '2025-02-11T11:08:45.070000+01:00' Name: /aws/service/powertools/typescript/generic/all/2.14.0 Type: String Value: arn:aws:lambda:eu-west-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42 Version: 1 |
We currently publish SSM parameters for the following Powertools for AWS Lambda versions in all commercial regions:
/aws/service/powertools/typescript/generic/all/latest: for the latest version of Powertools for AWS Lambda/aws/service/powertools/typescript/generic/all/{version}: for a specific version of Powertools for AWS Lambda (e.g.2.14.0)
See the examples below for how to use the SSM parameter in your infrastructure as code.
Want to inspect the contents of the Layer?¶
The pre-signed URL to download this Lambda Layer will be within Location key in the CLI output. The CLI output will also contain the Powertools for AWS Lambda version it contains.
Change {aws::region} to your AWS region, e.g. eu-west-1, and run the following command:
AWS CLI command to download Lambda Layer contentAWS CLI output
| aws lambda get-layer-version-by-arn --arn arn:aws:lambda:{aws::region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42 --region {aws::region} |
|---|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | { "Content": { "Location": "https://awslambda-eu-west-1-layers.s3.eu-west-1.amazonaws.com/...", "CodeSha256": "gwGIE8w0JckdDeDCTX6FbWObb2uIDwgiaAq78gMWDyA=", "CodeSize": 3548324 }, "LayerArn": "arn:aws:lambda:eu-west-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2", "LayerVersionArn": "arn:aws:lambda:eu-west-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42", "Description": "Powertools for AWS Lambda (TypeScript) version 2.18.0", "CreatedDate": "2025-04-08T07:38:30.424+0000", "Version": 24, "CompatibleRuntimes": [ "nodejs20.x", "nodejs22.x", "nodejs24.x" ], "LicenseInfo": "MIT-0", "CompatibleArchitectures": [ "arm64", "x86_64" ] } |
|---|
How to use with Infrastructure as Code¶
CDKSAMServerless frameworkTerraformPulumiAmplify
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import { Stack } from 'aws-cdk-lib'; import { Construct } from 'constructs'; import { LayerVersion, Function, Runtime, Code } from 'aws-cdk-lib/aws-lambda'; import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'; export class SampleFunctionWithLayer extends Construct { constructor(scope: Construct, id: string) { super(scope, id); // Create a Layer with Powertools for AWS Lambda (TypeScript) const powertoolsLayer = LayerVersion.fromLayerVersionArn( this, 'PowertoolsLayer', `arn:aws:lambda:${Stack.of(this).region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42` ); new NodejsFunction(this, 'Function', { runtime: Runtime.NODEJS_24_X, // Add the Layer to a Lambda function layers: [powertoolsLayer], code: Code.fromInline(`...`), handler: 'index.handler', }); } } |
|---|
If you use esbuild to bundle your code, make sure to exclude @aws-lambda-powertools/* and @aws-sdk/* from being bundled since the packages are already present the layer:
| new NodejsFunction(this, 'Function', { ... bundling: { externalModules: [ '@aws-lambda-powertools/*', '@aws-sdk/*', ], } }); |
|---|
Check the AWS CDK NodeJsFunction documentation for more details.
You can also use AWS SSM Parameter Store to dynamically resolve the Layer ARN from SSM Parameter Store and add the toolkit in your code, allowing you to pin to latest or a specific Powertools for AWS version.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import { Stack } from 'aws-cdk-lib'; import { Construct } from 'constructs'; import { LayerVersion, Function, Runtime, Code } from 'aws-cdk-lib/aws-lambda'; import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'; import { StringParameter } from 'aws-cdk-lib/aws-ssm'; export class SampleFunctionWithLayer extends Construct { constructor(scope: Construct, id: string) { super(scope, id); // Create a Layer with Powertools for AWS Lambda (TypeScript) const powertoolsLayer = LayerVersion.fromLayerVersionArn( this, 'PowertoolsLayer', StringParameter.valueForStringParameter(this, 'PowertoolsLayer', { parameterName: '/aws/service/powertools/typescript/generic/all/latest', }) ); new NodejsFunction(this, 'Function', { runtime: Runtime.NODEJS_24_X, // Add the Layer to a Lambda function layers: [powertoolsLayer], code: Code.fromInline(`...`), handler: 'index.handler', }); } } |
|---|
| MyLambdaFunction: Type: AWS::Serverless::Function Properties: Layers: - !Sub arn:aws:lambda:${AWS::Region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42 |
|---|
You can also use AWS SSM Parameter Store to dynamically add Powertools for AWS Lambda and resolve the Layer ARN from SSM Parameter Store in your code, allowing you to pin to latest or a specific Powertools for AWS Lambda version.
| MyLambdaFunction: Type: AWS::Serverless::Function Properties: Layers: - {{resolve:ssm:/aws/service/powertools/typescript/generic/all/latest}} |
|---|
If you use esbuild to bundle your code, make sure to exclude @aws-lambda-powertools/* and @aws-sdk/* from being bundled since the packages are already present the layer:
| 1 2 3 4 5 6 7 8 9 10 11 12 | MyLambdaFunction: Type: AWS::Serverless::Function Properties: ... Metadata: # Manage esbuild properties BuildMethod: esbuild BuildProperties: Minify: true External: - '@aws-lambda-powertools/*' - '@aws-sdk/*' |
|---|
Check the documentation for more details.
| functions: hello: handler: lambda_function.lambda_handler layers: - arn:aws:lambda:${aws:region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42 |
|---|
If you use esbuild to bundle your code, make sure to exclude @aws-lambda-powertools/* and @aws-sdk/* from being bundled since the packages are already present the layer:
| custom: esbuild: external: - '@aws-lambda-powertools/*' - '@aws-sdk/*' |
|---|
Check the documentation for more details.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | terraform { required_version = "~> 1.0.5" required_providers { aws = "~> 3.50.0" } } provider "aws" { region = "{aws::region}" } resource "aws_lambda_function" "test_lambda" { filename = "lambda_function_payload.zip" function_name = "lambda_function_name" role = ... handler = "index.handler" runtime = "nodejs24.x" layers = ["arn:aws:lambda:{aws::region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42"] source_code_hash = filebase64sha256("lambda_function_payload.zip") } |
|---|
You can use data sources to resolve the SSM Parameter Store in your code, allowing you to pin to latest or a specific Powertools for AWS Lambda version.
| 1 2 3 4 5 6 7 8 9 10 11 12 | data "aws_ssm_parameter" "powertools_version" { # Replace {version} with your chosen Powertools for AWS Lambda version or latest name = "/aws/service/powertools/python/generic/all/latest" } resource "aws_lambda_function" "test_lambda" { ... runtime = "nodejs24.x" layers = [data.aws_ssm_parameter.powertools_version.value] } |
|---|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import * as pulumi from '@pulumi/pulumi'; import * as aws from '@pulumi/aws'; const role = new aws.iam.Role('role', { assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal(aws.iam.Principals.LambdaPrincipal), managedPolicyArns: [aws.iam.ManagedPolicies.AWSLambdaBasicExecutionRole] }); const lambdaFunction = new aws.lambda.Function('function', { layers: [ pulumi.interpolate`arn:aws:lambda:${aws.getRegionOutput().name}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42` ], code: new pulumi.asset.FileArchive('lambda_function_payload.zip'), tracingConfig: { mode: 'Active' }, runtime: aws.lambda.Runtime.NodeJS24dX, handler: 'index.handler', role: role.arn, architectures: ['x86_64'] }); |
|---|
Remember to replace the region with your AWS region, e.g., eu-west-1. Amplify Gen 2 currently does not support obtaining the region dynamically.
| import { defineFunction } from "@aws-amplify/backend"; export const myFunction = defineFunction({ name: "my-function", layers: { "@aws-lambda-powertools/*": "arn:aws:lambda:${AWS::Region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:42", }, }); |
|---|
Dependency management¶
When using the Lambda Layer, the Powertools for AWS Lambda packages are already included in your Lambda runtime environment. However, you still need to install these packages locally for development, testing, and IDE support.
Since the packages are provided by the Lambda Layer at runtime, install them as devDependencies in your package.json file:
| Install Powertools for AWS Lambda packages | |
|---|---|
| 1 | npm i -D @aws-lambda-powertools/logger |
Important considerations:
- Exclude from bundling: Ensure your build process excludes these packages from your deployment bundle since they're provided by the layer
- Version synchronization: Keep your local development dependencies in sync with the Lambda Layer version to maintain consistency
Following these practices prevents version conflicts that can cause unexpected behavior, such as failed instanceof checks or inconsistent behavior between your local development environment and the Lambda execution environment.