Skip to content

fix(cli-internal): read DynamoDB event source properties from CFN template#14895

Open
adrianjoshua-strutt wants to merge 2 commits into
devfrom
fix/dynamo-trigger-props-14569
Open

fix(cli-internal): read DynamoDB event source properties from CFN template#14895
adrianjoshua-strutt wants to merge 2 commits into
devfrom
fix/dynamo-trigger-props-14569

Conversation

@adrianjoshua-strutt
Copy link
Copy Markdown
Member

Problem

When generating Lambda DynamoDB stream trigger wiring, the tool hardcoded StartingPosition to LATEST and ignored BatchSize from the Gen1 CloudFormation template's AWS::Lambda::EventSourceMapping resources. This meant customers using TRIM_HORIZON or custom batch sizes had their configuration silently discarded during migration.

Fixes #14569.

Solution

Detection changes

detectDynamoTriggerModels and detectStorageDynamoTriggers now return DetectedDynamoTrigger[] (carrying both the model/table name and the extracted properties) instead of plain string[].

Contribution changes

contributeDynamoTrigger and contributeStorageDynamoTrigger consume the new typed triggers and emit the correct StartingPosition and optional batchSize in the generated DynamoEventSource constructor.

Helpers

  • extractDynamoTriggerProps(): safely reads StartingPosition (default: LATEST) and BatchSize (omitted when absent) from CFN Properties.
  • createDynamoEventSourceProps(): builds the TypeScript object literal property assignments for the CDK constructor.

Testing

  • Added 3 new unit tests verifying TRIM_HORIZON reading, BatchSize reading, and LATEST fallback.
  • Updated the discussions snapshot app to include the newly emitted batchSize: 100 (present in its CFN template).
  • All 22 tests pass (10 unit + 12 snapshot).

@adrianjoshua-strutt adrianjoshua-strutt changed the base branch from gen2-migration to dev May 18, 2026 17:40
@adrianjoshua-strutt adrianjoshua-strutt marked this pull request as ready for review May 18, 2026 20:58
@adrianjoshua-strutt adrianjoshua-strutt requested a review from a team as a code owner May 18, 2026 20:58
…plate

Extract StartingPosition and BatchSize from EventSourceMapping CFN
resources instead of hardcoding LATEST. This allows the generated
code to preserve the original trigger configuration (e.g.,
TRIM_HORIZON, custom batch sizes).

---
Prompt: Fix dynamo trigger props to read from CFN template instead
of hardcoding LATEST.
@adrianjoshua-strutt adrianjoshua-strutt force-pushed the fix/dynamo-trigger-props-14569 branch from 32acee1 to 7ea9a12 Compare May 18, 2026 21:13
Generate separate addEventSource statements per DynamoDB trigger model
instead of a single for-of loop that incorrectly used triggers[0].props
for all models. This ensures each model gets its own StartingPosition
and BatchSize from the CFN EventSourceMapping resource.

Also adds 3 unit tests:
- Single trigger with custom BatchSize and StartingPosition
- Multiple triggers with different configs (proves the bug is fixed)
- Fallback to LATEST when StartingPosition is missing from CFN
sarayev
sarayev previously approved these changes May 19, 2026
Copy link
Copy Markdown
Contributor

@sarayev sarayev left a comment

Choose a reason for hiding this comment

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

Do we need to implement tests for those changes?

soberm
soberm previously approved these changes May 19, 2026
@adrianjoshua-strutt adrianjoshua-strutt dismissed stale reviews from soberm and sarayev via 90d40ae May 19, 2026 09:31
@adrianjoshua-strutt adrianjoshua-strutt self-assigned this May 19, 2026
@adrianjoshua-strutt
Copy link
Copy Markdown
Member Author

@sarayev I added tests

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.

(gen2-migration) generate command doesn't handle all properties when generating lambda API triggers

3 participants