Una tarea por función, arranques en frío medidos, handlers idempotentes, roles de mínimo privilegio.
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.
-
One job per function. Each Lambda handles one event source and one job. A function that routes on an
actionfield to unrelated work is split before it merges. -
Cold starts measured. Init duration is tracked per function from the
REPORTlog 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. -
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.
-
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. -
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. -
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.