Skip to content

(gen2-migration) generate command produces stacks with circular dependencies #14727

@iliapolo

Description

@iliapolo

How did you install the Amplify CLI?

Local

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

Local

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Describe the bug

Running npx amplify gen2-migration generate can result in a Gen2 app that cannot be deployed due to circular dependencies issues:

🛑 [CloudformationStackCircularDependencyError] circular dependency found between nested stacks [storage, auth, data, function]

Expected behavior

Resources should be placed in the correct stacks such that circular dependencies don't exist.

Reproduction steps

Fitness tracker suffers from this. We currently compensate by instructing the user to change the resourceGroupName property of the function.

Project Identifier

No response

Log output

Details
# Put your logs below this line


Additional information

In addition, when a function accesses multiple resources, the access property on defineAuth creates a dependency auth -> function. If that function also accesses another category, say data, we now have an auth -> data dependency which creates a circle. Same thing happens with storage. So resourceGroupName alone doesn't fix the problem.

If however direct function.addToRolePolicy CDK is used, this dependency is avoided because it preserves the function -> auth direction, not the reverse.

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions