-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Unexpected stack circular dependency when subscribing a lambda in one stack to a SNS topic in another stack #1643
Comments
Looks like the subscription is created in the stack that owns the Topic and references the Function. A permission is then added to the Function referencing the topic, completing the circular dependency. I think the solution is to always created the subscription in the function's stack. |
Try working around by explicitly exporting the topic and importing into the lambda stack: subscribedLambda.addEventSource(new lambdaEvents.SnsEventSource(
sns.Topic.import(this, 'Topic', props.toCrawlTopic.export()))); I think this is a subtle edge-case of the cross-stack automatic import/export feature. Before, manually exporting and importing the topic would have placed the topic in the subscribers stack, so calling subscribeLambda would place the |
I think this is a duplicate. Let me check. But you're right, we need to create the sub under the queue |
Oh wait, it's a different occurrence of the same pattern. |
Awesome thanks @rix0rrr @sam-goodwin! |
Create the SNS Subscription object under the subscriber instead of the subscribee, avoiding cyclic stack dependencies if those objects would be in different stacks. Fixes #1643, fixes #1534. DEPLOYMENT IMPACT: this will recreate any subscription objects under new names. It should not have visible impact on your deployments.
Is there a way to do the export import method under python? I've been running into a similar issue with api gateway and lambda being declared and linked in two separate stacks. |
The following code is attempting to make an SNS topic in one stack, and a Lambda in another stack
However when I deploy I get this error:
My expectation is that the
npm-follower
stack would get a dependency on theshared-resources
stack but not the other way around. Somehow it becomes a circular dependency thoughThe text was updated successfully, but these errors were encountered: