A Lambda writes to DynamoDB using PutItem and sometimes duplicates writes when clients retry after timeouts. The table uses a composite primary key (orderId, eventTime). Which strategy provides end-to-end idempotency without requiring exactly-once execution?

Answer

Use a conditional expression on a deterministic attribute so only the first write succeeds, and retry uses the same deterministic condition

Explanation

Idempotency should be enforced with deterministic keys/conditions so retries converge to the same outcome. Conditional expressions (e.g., attribute_not_exists on a stable marker) prevent duplicates regardless of invocation multiplicity.

Last reviewed: October 2026

Reviewed by FirstInTest Editorial Team

Report an error
QuestionBack to list