fix(gen2-migration): skip imported auth resources in refactor step#14722
Merged
iliapolo merged 1 commit intogen2-migrationfrom Mar 30, 2026
Merged
fix(gen2-migration): skip imported auth resources in refactor step#14722iliapolo merged 1 commit intogen2-migrationfrom
iliapolo merged 1 commit intogen2-migrationfrom
Conversation
Imported (reference) auth resources have no nested CloudFormation stack — they reference externally-managed Cognito resources. The refactor step was unconditionally creating an AuthCognitoForwardRefactorer for every auth:Cognito resource, which then failed with "unable to find source stack" because there is no stack to find. Now checks serviceType === 'imported' in amplify-meta.json before creating the refactorer, matching the existing pattern in the generate step. Added tests for both forward and rollback paths. --- Prompt: In the gen2-migration tool, I am getting this error when trying to refactor an app with an imported auth resource - "[AuthCognitoForwardRefactorer] unable to find source stack"
iliapolo
approved these changes
Mar 30, 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.
When you run
amplify gen2-migration refactoron an app with an imported auth resource, the refactor step was crashing with "unable to find source stack." That's because imported auth resources are just references to externally-managed Cognito resources — they don't have a nested CloudFormation stack in the Gen1 root stack. Therefactorwas trying to find one and failing.The generate step already handled this correctly — it checks serviceType === 'imported' in amplify-meta.json and uses a ReferenceAuthGenerator instead of the normal AuthGenerator. The refactor step had no such check.
The fix adds the same check to refactor.ts in both forward() and rollback(). When the auth resource is imported, we skip creating the AuthCognitoForwardRefactorer / AuthCognitoRollbackRefactorer entirely — there's nothing to move.
Source of truth -
amplify-cli/packages/amplify-cli/src/commands/gen2-migration/generate.ts
Line 81 in 4f88963