feat(gen2-migration): kinesis triggers codegen for gen2-migration#14787
Merged
iliapolo merged 5 commits intogen2-migrationfrom Apr 16, 2026
Merged
Conversation
…tion generate When a Gen1 function's CFN template contains an AWS::Lambda::EventSourceMapping referencing a Kinesis stream ARN, the generated Gen2 backend.ts now wires the function as a Kinesis trigger using KinesisEventSource with Stream.fromStreamArn(). Codegen changes in function.generator.ts: - detectKinesisTrigger() scans CFN for EventSourceMapping with Ref: analytics<name>kinesisStreamArn - contributeKinesisTrigger() emits Stream.fromStreamArn(), KinesisEventSource, and addEventSource() in backend.ts - Both Kinesis IAM grants and event source permissions are kept (no permission scope reduction) Mood-board E2E app changes: - Added KinesisEventCount model to GraphQL schema - Created moodboard2604151154c448f847 Kinesis trigger function - Updated configure.sh, post-generate.ts, App.tsx, README.md - Added KinesisTriggerLogs.tsx UI component - Added kinesis-trigger.test.ts E2E test - All 4 snapshots updated from passing E2E run (22 Gen1 + 22 Gen2 tests green) Tested by running the full E2E system with UPDATE_SNAPSHOTS=1. All 44 tests pass (22 Gen1, 22 Gen2) including the new kinesis trigger test on both sides. --- Prompt: Implement Kinesis Stream Trigger Migration for gen2-migration generate. Add codegen support for migrating Gen1 Kinesis Stream Lambda triggers. When a Gen1 function's CFN template contains an EventSourceMapping referencing a Kinesis stream ARN, generate KinesisEventSource wiring in the Gen2 backend.ts.
…inesisTrigger Rename the auto-generated function name moodboard2604151154c448f847 to the human-readable moodboardKinesisTrigger across all mood-board E2E app snapshots, migration scripts, and source files. E2E verified: 22/22 Gen1 tests passed, 22/22 Gen2 tests passed, snapshots match. --- Prompt: rename moodboard2604151154c448f847 to moodboardKinesisTrigger for readability in the mood-board E2E app
Fix generate snapshot: add amplify_outputs* to .gitignore, fix KinesisEventCount table mapping formatting in data/resource.ts. Fix refactor snapshot: update storage S3 auto-delete custom resource ARNs to match unit test mock physical ID format (stackName/logicalId fallback for resources without CFN outputs). --- Prompt: fix snapshot test failures for mood-board generate and refactor tests
Rename `record` to `_record` in the Kinesis trigger handler loop to satisfy unused-variable lint rules. The loop body uses the iteration count, not the record contents. --- Prompt: fix unused variable lint warning in kinesis trigger handler
iliapolo
reviewed
Apr 16, 2026
The moodboardKinesisTrigger function directory always exists in the snapshot, so the conditional check is not needed. --- Prompt: remove unnecessary fallback guard in configure.sh for kinesis trigger copy
sai-ray
commented
Apr 16, 2026
iliapolo
approved these changes
Apr 16, 2026
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 of changes
This PR adds codegen support for migrating Gen1 Kinesis Stream Lambda triggers in
gen2-migration generate. When a Gen1 function's CloudFormation template contains anAWS::Lambda::EventSourceMappingreferencing a Kinesis stream ARN, the generated Gen2backend.tswires the function as a Kinesis trigger using CDK'sKinesisEventSource.Codegen
The function generator gains two new methods:
detectKinesisTrigger()scans the CFN template for anEventSourceMappingwithRef: analytics<name>kinesisStreamArnand returns whether the function is a Kinesis trigger.contributeKinesisTrigger()emitsStream.fromStreamArn()+KinesisEventSource+addEventSource()intobackend.ts. We useStream.fromStreamArn()because the analytics construct only exposes the ARN (L1CfnStream), not an L2Stream.The existing
contributeKinesisGrants()(IAM policy grants) is kept separate — it handles functions that call Kinesis APIs via SDK. The event source approach automatically grants the necessary read permissions through CDK, so there's no duplication.Mood-board E2E app
KinesisEventCountmodel to the GraphQL schema andmoodboardKinesisTriggerfunction that processes Kinesis stream records and writes event counts to AppSync.KinesisTriggerLogs.tsxUI component andkinesis-trigger.test.tsE2E test.configure.sh,post-generate.ts,App.tsx, andREADME.md.Issue #, if available
Fixes #14601
Follows the pattern established by the DynamoDB trigger PR (#14766).
Description of how you validated changes
npm run test:e2e) withoutUPDATE_SNAPSHOTS— all 22 Gen1 tests passed, all 22 Gen2 tests passed, snapshots matched.analytics/moodboardKinesis.yarn testinpackages/amplify-cli/— generate and refactor snapshot tests pass for mood-board.Checklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.