Skip to content

CCM-13519 Add idempotency layer in front of upsert#546

Open
stevebux wants to merge 3 commits intomainfrom
feature/CCM-13519-Upsert-Idempotency-Layer
Open

CCM-13519 Add idempotency layer in front of upsert#546
stevebux wants to merge 3 commits intomainfrom
feature/CCM-13519-Upsert-Idempotency-Layer

Conversation

@stevebux
Copy link
Copy Markdown
Contributor

Description

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

DT3-Specific Checklist

  • If I have added a new resource (SQS, Lambda, Gateway, DDB table, etc), I have created the appropriate alarms

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.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread package.json Outdated
Comment thread tests/helpers/event-fixtures.ts
Comment thread lambdas/upsert-letter/src/handler/upsert-handler.ts
Comment thread lambdas/upsert-letter/src/handler/upsert-handler.ts
Comment thread lambdas/upsert-letter/src/handler/upsert-handler.ts
Comment thread lambdas/upsert-letter/src/handler/__tests__/upsert-handler.test.ts
@stevebux stevebux force-pushed the feature/CCM-13519-Upsert-Idempotency-Layer branch from bfed80a to ebb5b3b Compare April 24, 2026 10:35
@stevebux stevebux force-pushed the feature/CCM-13519-Upsert-Idempotency-Layer branch from ebb5b3b to 52b2165 Compare April 24, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants