|
| 1 | +import { getCustomStaticPath } from '@/utils/getCustomStaticPath'; |
| 2 | + |
| 3 | +export const meta = { |
| 4 | + title: 'Troubleshoot circular dependency issues', |
| 5 | + description: 'Addressing deployment failures caused by circular dependencies', |
| 6 | + platforms: [ |
| 7 | + 'angular', |
| 8 | + 'javascript', |
| 9 | + 'nextjs', |
| 10 | + 'react', |
| 11 | + 'react-native', |
| 12 | + 'vue' |
| 13 | + ] |
| 14 | +}; |
| 15 | + |
| 16 | +export function getStaticPaths() { |
| 17 | + return getCustomStaticPath(meta.platforms); |
| 18 | +} |
| 19 | + |
| 20 | +export function getStaticProps(context) { |
| 21 | + return { |
| 22 | + props: { |
| 23 | + meta |
| 24 | + } |
| 25 | + }; |
| 26 | +} |
| 27 | + |
| 28 | +When deploying a Amplify Gen 2 app, you may encounter the error message `The CloudFormation deployment failed due to circular dependency` in your backend build on Amplify Console or while running a sandbox. This error can occur because of circular dependencies between cloudformation nested stacks or between resources in a single cloudformation stack. |
| 29 | + |
| 30 | +## Circular dependency error between nested stacks |
| 31 | + |
| 32 | +If you see this error "The CloudFormation deployment failed due to circular dependency found between nested stacks [data1234ABCD, function6789XYZ]", it means that the nested stack for data and the nested stack for function have circular dependencies. E.g. if you are using the function as a query handler, but the function also needs access to the data (or AppSync) API, you might run into this issue. To resolve, assign this function to the data stack |
| 33 | + |
| 34 | +```ts title="function.ts" |
| 35 | +export const queryFunction = defineFunction({ |
| 36 | + name: 'myFunction', |
| 37 | + entry: '../handler.ts', |
| 38 | + resourceGroupName: 'data', |
| 39 | +}); |
| 40 | +``` |
| 41 | + |
| 42 | +Similarly, if you are using your function as an auth trigger, you can assign your function to the auth stack to break the circular dependency. |
| 43 | + |
| 44 | +```ts title="function.ts" |
| 45 | +export const preSignUpTrigger = defineFunction({ |
| 46 | + name: 'myFunction', |
| 47 | + entry: '../handler.ts', |
| 48 | + resourceGroupName: 'auth', |
| 49 | +}); |
| 50 | +``` |
| 51 | + |
| 52 | +If you are unable to resolve this error using function's `resourceGroupName` property, please create an issue [here](https://github.com/aws-amplify/amplify-backend/issues/new/choose) |
| 53 | + |
| 54 | +## Circular dependency error between resources in the same stack |
| 55 | + |
| 56 | +If you see this error "The CloudFormation deployment failed due to circular dependency found between resources [resource1, resource2] in a single stack", that means the resources themselves have a circular dependency in the same stack. For handling such errors, see https://aws.amazon.com/blogs/infrastructure-and-automation/handling-circular-dependency-errors-in-aws-cloudformation/ |
0 commit comments