feat(gen2-migration): lambda access to kinesis streams#14644
Open
sai-ray wants to merge 2 commits intogen2-migrationfrom
Open
feat(gen2-migration): lambda access to kinesis streams#14644sai-ray wants to merge 2 commits intogen2-migrationfrom
sai-ray wants to merge 2 commits intogen2-migrationfrom
Conversation
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.
Fixes: #14620
Description
This PR extends the migration codegen pipeline to detect and preserve Kinesis stream access for Lambda functions during Amplify gen1 to gen2 migration, following the same pattern used for DynamoDB and S3 function access.
Changes
New
KinesisCloudFormationAccessParser(codegen-head/kinesis_cfn_access_parser.ts) reads each function's Gen1 CFN template and extractskinesis:*IAM actions from theAmplifyResourcesPolicyresource. Follows the same pattern asDynamoDBCloudFormationAccessParserandS3CloudFormationAccessParser.New
extractFunctionKinesisAccess()inadapters/analytics/analytics_access.tsaggregates per-function Kinesis permissions intoFunctionKinesisAccess[].Function adapter (
adapters/functions/index.ts) now filtersANALYTICS_*_KINESISSTREAMARNenv vars intofilteredEnvironmentVariables, same as existingSTORAGE_*andAUTH_*filtering.Lambda env generator (
generators/functions/lambda_env_generator.ts) mapsANALYTICS_.*_KINESISSTREAMARNtoanalytics.kinesisStreamArnusing a direct variable reference (isDirect = true) sinceanalyticsis a standalone CDK construct, not accessed viabackend..BackendSynthesizer(backend/synthesizer.ts) extended withfunctionsWithKinesisAccessonBackendRenderParameters.analytics. GeneratesaddToRolePolicy()calls withaws_iam.PolicyStatementfor each function with Kinesis access, and adds theaws_iamimport fromaws-cdk-lib.Migration pipeline (
core/migration-pipeline.ts) callsextractFunctionKinesisAccess(functionNames)and passes results tobackendRenderOptions.analytics.functionsWithKinesisAccess.Input:
IAM Permissions
Environment Variable
Output (
backend.ts)Issue #, if available
Description of how you validated changes
Tested migration on an Amplify Gen1 app containing lambda function reading from a kinesis stream.
Checklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.