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).
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:
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:
{"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:30","Description":"Powertools for AWS Lambda (TypeScript) version 2.18.0","CreatedDate":"2025-04-08T07:38:30.424+0000","Version":24,"CompatibleRuntimes":["nodejs18.x","nodejs20.x","nodejs22.x"],"LicenseInfo":"MIT-0","CompatibleArchitectures":["arm64","x86_64"]}
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';exportclassSampleFunctionWithLayerextendsConstruct{constructor(scope:Construct,id:string){super(scope,id);// Create a Layer with Powertools for AWS Lambda (TypeScript)constpowertoolsLayer=LayerVersion.fromLayerVersionArn(this,'PowertoolsLayer',`arn:aws:lambda:${Stack.of(this).region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:30`);newNodejsFunction(this,'Function',{runtime:Runtime.NODEJS_22_X,// Add the Layer to a Lambda functionlayers:[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:
Check the AWS CDK NodeJsFunctiondocumentation 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.
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';exportclassSampleFunctionWithLayerextendsConstruct{constructor(scope:Construct,id:string){super(scope,id);// Create a Layer with Powertools for AWS Lambda (TypeScript)constpowertoolsLayer=LayerVersion.fromLayerVersionArn(this,'PowertoolsLayer',StringParameter.valueForStringParameter(this,'PowertoolsLayer',{parameterName:'/aws/service/powertools/typescript/generic/all/latest',}));newNodejsFunction(this,'Function',{runtime:Runtime.NODEJS_22_X,// Add the Layer to a Lambda functionlayers:[powertoolsLayer],code:Code.fromInline(`...`),handler:'index.handler',});}}
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.
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:
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:
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 9101112
data"aws_ssm_parameter""powertools_version"{ # Replace {version} with your chosen Powertools for AWS Lambda version or latestname="/aws/service/powertools/python/generic/all/latest"}resource"aws_lambda_function""test_lambda"{...runtime="nodejs22.x"layers=[data.aws_ssm_parameter.powertools_version.value]}
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
npmi-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.