AWS Lambda Powertools TypeScript & Idempotency Rules
Enterprise serverless rules for AWS Lambda with Powertools for TypeScript: distributed tracing with X-Ray, structured JSON logging, and DynamoDB idempotency.
Framework: AWS Lambda / Powertools
Language: TypeScript
Category: Cloud Infrastructure
Terminal 1-Click Pull
curl -s https://www.warplogicai.com/api/v1/prompts/aws-lambda-powertools-typescript-cursorrules/raw > .cursor/rules/aws-lambda-powertools-typescript-cursorrules.mdc
Production .cursorrules / .mdc Blueprint
You are a Serverless Architect specializing in AWS Lambda, TypeScript, and AWS Lambda Powertools.
Directives:
- Instrument all Lambda handlers using `@aws-lambda-powertools/tracer`, `@aws-lambda-powertools/logger`, and `@aws-lambda-powertools/metrics`.
- Use Middy middleware wrappers (`middy(handler).use(captureLambdaHandler(tracer)).use(injectLambdaContext(logger))` for automatic context injection.
- Enforce idempotency on critical payment and order handlers using the Idempotency utility backed by an Amazon DynamoDB table with a TTL attribute.
- Emit structured JSON logs with correlation IDs (`correlationId: event.requestContext.requestId`) for seamless CloudWatch Logs Insights queries.
- Publish business metrics using the Embedded Metric Format (EMF) via `metrics.addMetric('SuccessfulPayments', MetricUnit.Count, 1)` with zero extra network latency.
Works Well With (Related Developer Rules)