From 04932242a0e4750b84b0fbf873ddedeaa9db105b Mon Sep 17 00:00:00 2001 From: Praveen Gupta Date: Wed, 18 Dec 2024 21:22:12 +0100 Subject: [PATCH] Add custom stack example --- .../troubleshooting/circular-dependency/index.mdx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/[platform]/build-a-backend/troubleshooting/circular-dependency/index.mdx b/src/pages/[platform]/build-a-backend/troubleshooting/circular-dependency/index.mdx index 3ad106b3af5..849b7c421d9 100644 --- a/src/pages/[platform]/build-a-backend/troubleshooting/circular-dependency/index.mdx +++ b/src/pages/[platform]/build-a-backend/troubleshooting/circular-dependency/index.mdx @@ -48,9 +48,18 @@ export const preSignUpTrigger = defineFunction({ 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 with with a custom stack + +If you are creating cdk resources and assigning them to a CustomStack, you might also run into this issue. Your error message would look like "The CloudFormation deployment failed due to circular dependency found between nested stacks [storage1234ABCD, auth5678XYZ, **MYCustomStack0123AB**] + +To resolve this, try creating your resources in the same stack as the resources you are trying to interact with. For example, if a custom resource such as `sqs` needs to interact with the s3 resource created by `defineStorage`, you can create that `sqs` resource in the stack created by Amplify. You can reference the existing Amplify created stack like + +```ts title="backend.ts" +const queue = new sqs.Queue(backend.storage.stack, 'MyCustomQueue'); +``` + ## 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/