S3 SqsDestination and SnsDestination creates a cyclic reference
See original GitHub issueReproduction Steps
const app1= new cdk.App();
const stack1 = new cdk.Stack(app, "stack1");
const stack2 = new cdk.Stack(app, "stack2");
const topic = new Topic(stack2, 'Topic');
const bucket = new s3.Bucket(stack1, "bucket");
bucket.addEventNotification( EventType.OBJECT_CREATED_PUT, new s3n.SnsDestination(topic));
$ cdk synth
What actually happened?
Error: 'stack1' depends on 'stack2' ("stack1/bucket/Notifications/Resource" depends on "stack2/Topic/Resource", "stack1/bucket/Notifications/Resource" depends on "stack2/Topic/Policy/Resource", stack1 -> stack2/Topic/Resource.Ref). Adding this dependency (stack2 -> stack1/bucket/Resource.Arn) would create a cyclic reference.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:14
Top Results From Across the Web
CDK - S3 notification causing cyclic reference error
The error message indicates, that you use a Lambda. Where is that Lamdba definition? What are you trying to do with SNS?
Read more >Resolving circular dependency in provisioning of Amazon S3 ...
When customers attempt to deploy this setup in CloudFormation, it results in a deployment failure due to a circular dependency between the ...
Read more >@aws-cdk/aws-s3-notifications | Yarn - Package Manager
Bucket Notifications API for AWS S3 ... The following example shows how to send a notification to an SNS topic when an object...
Read more >@aws-cdk/aws-s3-notifications - npm
The following example shows how to send a notification to an SNS topic when an object is created in an S3 bucket:.
Read more >Getting around circular CloudFormation Dependencies: S3 ...
We can do that by first creating the bucket and the lambda function and bringing them together after that. The way to extend...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1
Other possible workaround is to use AwsCustomResource. You basically specify an AWS SDK call to be executed onCreate, onUpdate or onDelete - internally this creates a Lambda that will do the real work: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#custom-resources-for-aws-apis
Note: This replaces the existing notification configuration with the configuration you include in the parameter. Check: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotificationConfiguration.html