aws-amplify / aws-amplify/amplify-cli

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

Open
#14,727 1 comment 2 reactions 1 assignee Claimed by @sharonyajain View on GitHub
gen2-migration
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### 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:

```console
🛑 [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](https://github.com/aws-amplify/amplify-cli/blob/gen2-migration/amplify-migration-apps/fitness-tracker/README.md) suffers from this. We currently compensate by instructing the user to change the `resourceGroupName` property of the function.

### Project Identifier

_No response_

### Log output

```
# 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:

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.