Skip to content

fix(gen2-migration): skip imported auth resources in refactor step#14722

Merged
iliapolo merged 1 commit intogen2-migrationfrom
dgandhi62-patch-3
Mar 30, 2026
Merged

fix(gen2-migration): skip imported auth resources in refactor step#14722
iliapolo merged 1 commit intogen2-migrationfrom
dgandhi62-patch-3

Conversation

@dgandhi62
Copy link
Copy Markdown
Contributor

@dgandhi62 dgandhi62 commented Mar 30, 2026

When you run amplify gen2-migration refactor on 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. The refactor was 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 -

const meta = (gen1App.meta('auth') ?? {})[r.resourceName] as Record<string, unknown> | undefined;

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"
@dgandhi62 dgandhi62 requested a review from a team as a code owner March 30, 2026 19:04
@iliapolo iliapolo enabled auto-merge (squash) March 30, 2026 19:11
@iliapolo iliapolo merged commit 2b3ba3c into gen2-migration Mar 30, 2026
4 checks passed
@iliapolo iliapolo deleted the dgandhi62-patch-3 branch March 30, 2026 19:12
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.

2 participants