feat(cli): support custom CDK resource migration in gen2-migration generate#14863
Open
sanjanaravikumar-az wants to merge 12 commits intodevfrom
Open
feat(cli): support custom CDK resource migration in gen2-migration generate#14863sanjanaravikumar-az wants to merge 12 commits intodevfrom
sanjanaravikumar-az wants to merge 12 commits intodevfrom
Conversation
…Backend type Update the custom resource generator to: - Return the construct instance from defineXxx() wrapper functions - Use Backend type annotation instead of any for the backend parameter - Rename cdk-stack.ts to construct.ts (not resource.ts) - Use _prefixed variable name in post-generate to avoid shadowing - Fix post-generate to look in construct.ts for table name pattern - Update snapshots and tests to match
iliapolo
requested changes
May 6, 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
Adds support for migrating Gen1 custom CDK resources (
amplify/backend/custom/*) to Gen2 duringamplify gen2-migration generate.What it does
When a Gen1 app has custom CDK resources (category
custom, servicecustomCDK), the migration tool now:custom:customCDKinKNOWN_RESOURCE_KEYSamplify/custom/<name>/cdk-stack.tsvia AST rewriting (removes Gen1 helpers, rewrites dependency references, changesextends Stacktoextends Construct, renames class)cdk-stack.ts→construct.tsresource.tswrapper withdefineXxx(backend)factory functionpackage.jsondefineXxx(backend)call tobackend.tsAlso includes the
finance-trackermigration app which exercises two custom resources (customfinancefor SNS topics,customresolverfor a custom VTL resolver).Key design decisions
construct.ts+resource.tswrapper pattern (unlike other categories that export directly). The wrapper returns the construct instance so post-generate scripts can access its properties.AmplifyHelperTransformerrewrites Gen1 patterns to Gen2 equivalents via TypeScript AST transformation — handlesAmplifyHelpers.getProjectInfo(),addResourceDependency,CfnParameter('env'), CDK v1 imports, and dependency property access chains.RootPackageJsonGeneratornow usesmaxVersiondeduplication and strips CDK v1 / Gen1-only packages.Issue #, if available
generatecommand produces incorrect output for custom resource #14663Description of how you validated changes
npm run test:e2eon finance-tracker appChecklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.