-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: add troubleshooting for circular dependency errors in backend #8171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f1b424e
chore: add troubleshooting for circular dependency errors in backend
Amplifiyer 0174d70
Update src/pages/[platform]/build-a-backend/troubleshooting/circular-…
Amplifiyer 0493224
Add custom stack example
Amplifiyer 1ad8cdd
PR updates
Amplifiyer 20d9a42
PR updates
Amplifiyer 6f6f3bb
PR updates
Amplifiyer 884dfc9
Update src/pages/[platform]/build-a-backend/troubleshooting/circular-…
Amplifiyer ac37709
Update src/pages/[platform]/build-a-backend/troubleshooting/circular-…
Amplifiyer 889da3e
Apply suggestions from code review
Amplifiyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
56 changes: 56 additions & 0 deletions
56
src/pages/[platform]/build-a-backend/troubleshooting/circular-dependency/index.mdx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { getCustomStaticPath } from '@/utils/getCustomStaticPath'; | ||
|
||
export const meta = { | ||
title: 'Troubleshoot circular dependency issues', | ||
description: 'Addressing deployment failures caused by circular dependencies', | ||
platforms: [ | ||
'angular', | ||
'javascript', | ||
'nextjs', | ||
'react', | ||
'react-native', | ||
'vue' | ||
] | ||
}; | ||
|
||
export function getStaticPaths() { | ||
return getCustomStaticPath(meta.platforms); | ||
} | ||
|
||
export function getStaticProps(context) { | ||
return { | ||
props: { | ||
meta | ||
} | ||
}; | ||
} | ||
|
||
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. | ||
|
||
## Circular dependency error between nested stacks | ||
|
||
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 | ||
Amplifiyer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```ts title="function.ts" | ||
Amplifiyer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
export const queryFunction = defineFunction({ | ||
name: 'myFunction', | ||
Amplifiyer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
entry: '../handler.ts', | ||
Amplifiyer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
resourceGroupName: 'data', | ||
}); | ||
``` | ||
|
||
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. | ||
|
||
```ts title="function.ts" | ||
export const preSignUpTrigger = defineFunction({ | ||
name: 'myFunction', | ||
entry: '../handler.ts', | ||
Amplifiyer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
resourceGroupName: 'auth', | ||
}); | ||
``` | ||
|
||
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) | ||
|
||
## Circular dependency error between resources in the same stack | ||
|
||
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/ | ||
Amplifiyer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.