CCM-13519 Add idempotency layer in front of upsert#546
Open
CCM-13519 Add idempotency layer in front of upsert#546
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an AWS Lambda Powertools idempotency layer to the upsert-letter Lambda so repeated deliveries of the same event can be safely deduplicated using a dedicated DynamoDB table.
Changes:
- Introduces Powertools idempotency (
makeIdempotent+ DynamoDB persistence layer) around per-record upsert processing. - Adds a new DynamoDB table and Terraform wiring (env var + IAM) to persist idempotency records.
- Updates tests/fixtures and package manifests to support the new idempotency behavior and infra.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/helpers/event-fixtures.ts | Adjusts prepared event fixture generation (random IDs + override spreading). |
| package.json | Adds Powertools idempotency dependency at repo root (in addition to workspace). |
| package-lock.json | Locks Powertools idempotency and transitive dependencies. |
| lambdas/upsert-letter/src/handler/upsert-handler.ts | Wraps record processing with Powertools idempotency, adds context handling. |
| lambdas/upsert-letter/src/handler/tests/upsert-handler.test.ts | Adds idempotency mocking and a replay-focused unit test. |
| lambdas/upsert-letter/src/config/env.ts | Adds required env var for idempotency table name. |
| lambdas/upsert-letter/src/config/deps.ts | Adds DynamoDB persistence layer to dependency container. |
| lambdas/upsert-letter/src/config/tests/env.test.ts | Updates env var loading test to include new required var. |
| lambdas/upsert-letter/package.json | Adds Powertools idempotency dependency to the lambda workspace package. |
| infrastructure/terraform/components/api/module_lambda_upsert_letter.tf | Passes idempotency table name to Lambda and grants DynamoDB access. |
| infrastructure/terraform/components/api/ddb_table_upsert_idempotency.tf | Creates DynamoDB table used by the idempotency persistence layer. |
bfed80a to
ebb5b3b
Compare
ebb5b3b to
52b2165
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Context
Type of changes
Checklist
DT3-Specific Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.