Powertools for AWS Lambda (TypeScript) helps implement serverless best practices in Lambda handlers. Utilities install as separate npm packages or Lambda layers for TypeScript and JavaScript.
Overview
Powertools for AWS Lambda (TypeScript) is a modular developer toolkit aimed at AWS Lambda function code. Each utility ships as its own npm package so teams adopt only tracing, logging, metrics, routing, parameters, idempotency, batch handling, parsing, validation, Kafka helpers, signing, feature flags, or data masking as needed.
Core modules include structured logging with Lambda context enrichment, tracing decorators, custom metrics via CloudWatch Embedded Metric Format, lightweight HTTP routing for API Gateway and similar event sources, and high-level accessors for SSM, Secrets Manager, AppConfig, and DynamoDB parameters. Idempotency decorators and middleware reduce duplicate work from repeated payloads. Batch utilities address partial failures from SQS, Kinesis, and DynamoDB streams.
Parser and validation utilities lean on Zod or JSON Schema, with JMESPath helpers for common encoded JSON shapes. Kafka, SigV4 signing, and data masking utilities extend handlers that talk to streams, signed AWS HTTP endpoints, or sensitive fields. The toolkit optimizes for Lambda runtimes only and follows AWS Well-Architected serverless guidance as its primary goal.
Install via npm for each module or use pre-built Lambda layers. The same Powertools family exists for Python, Java, and .NET. Design tenets emphasize a lean dependency footprint, backward compatibility, and incremental adoption.
Key features
- Structured Lambda logging utility
- Tracing for sync and async handlers
- CloudWatch EMF custom metrics
- API Gateway and ALB event routing
- SSM Secrets Manager parameter helpers
- Idempotency middleware and decorators
- SQS Kinesis partial batch failure handling
- Zod and JSON Schema event validation
Use cases
- Standardizing observability in Lambda functions
- Reducing boilerplate for API Lambda handlers
- Safe retries with idempotent handlers
- Validating inbound Lambda event payloads
- Fetching secrets and config at runtime