← Tutti i modelli

Un compito per funzione, cold start misurati, handler idempotenti, ruoli con privilegi minimi.

Constitution — Serverless functions

Version 1.0.0 · Ratified 2026-11-10

These principles hold for every spec, plan and task of the project. A spec may add rules; it never weakens these.

  1. One job per function. Each Lambda handles one event source and one job. A function that routes on an action field to unrelated work is split before it merges.

  2. Cold starts measured. Init duration is tracked per function from the REPORT log lines. Bundles are tree-shaken with esbuild, SDK clients are created outside the handler, and a cold start over the budget set in the plan fails the release.

  3. Idempotent handlers. Every handler can receive the same event twice and leave the same result: writes use an idempotency key (Powertools idempotency or a conditional write in DynamoDB). Retries and redelivery are expected, not exceptional.

  4. Least-privilege roles. Each function has its own IAM role listing only the actions and resource ARNs it uses. A wildcard * in an action or resource fails the review.

  5. Failures go somewhere. Async invocations and queue consumers have a dead-letter queue or an on-failure destination, and SQS handlers report partial batch failures with batchItemFailures. The dead-letter queue has an alarm.

  6. Infrastructure as code. Functions, roles, queues and their timeouts and memory settings are defined in CDK, SAM or Terraform in the repository. Nothing is changed in the console; drift is a defect.