-
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
(@aws-cdk/aws-sns-subscriptions): Nested stack cannot depend on a parent stack error when trying to add SNS subscription #18829
Comments
A hacky workaround for this issue, is to create a So change this:
to something like this:
|
@jeffreyyoung thanks for the proposed solution. Just interesting if it is a bug or was intentionally done like this. |
Yeah, I'm not sure! Also not sure if the workaround I mentioned would cause other problems. 🤷♂️ |
I feel like this is a true circular dependency. Nested stacks cannot depend on their parents, so we can't depend on the topic existing in the nested stack. However, I feel like something like this should work, though I'm not very familiar with nested stacks: Parent stack: const topic = new Topic(this, 'topic', ...);
const nestedStack = new SomeNestedStack(this,...);
topic.addSubscription(new SqsSubscription(nestedStack.queue, ...)); Nested stack: readonly queue: Queue;
constructor(scope: ParentStack, ...) {
...;
this.queue = new Queue(...);
} But this runs into the same error as above. @corymhall is this a use case that was considered in #17273? I don't have a strong understanding of our nested stack model; perhaps what i'm describing isn't possible either. |
|
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
I have the same issue. Whenever I pass new SpecialistLambdas(this, "SpecialistLambdas", {
topic: this.beautyPageTopic
}) and use it like this #registerEventHandler() {
const subscription = new LambdaSubscription(this, {
filterPolicyWithMessageBody: {
type: FilterOrPolicy.filter(SubscriptionFilter.stringFilter({
allowlist: [BeautyPageEventType.SpecialistLabelUpdated]
}))
}
})
this.#props.beautyPageTopic.addSubscription(subscription)
} It says the following issue
Is it still an issue or am I doing something wrong? |
What is the problem?
I got the error that nested stack cannot depend on a parent stack when trying to add SNS subscription to topic from parent stack in nested one.
Reproduction Steps
Parent stack:
Some Nested stack:
What did you expect to happen?
Probably should not get this error.
What actually happened?
Got the following error:
Error: Nested stack 'nestedStack' cannot depend on a parent stack 'parentStack': undefined
at Object.addDependency (/builds/xymatic/bouncr/infra/node_modules/@aws-cdk/core/lib/deps.ts:73:11)
at stackName.addDependency (/builds/xymatic/bouncr/infra/node_modules/@aws-cdk/core/lib/stack.ts:271:5)
at SqsSubscription.bind (/builds/xymatic/bouncr/infra/node_modules/@aws-cdk/aws-sns-subscriptions/lib/sqs.ts:55:24)
CDK CLI Version
1.143.0
Framework Version
1.143.0
Node.js Version
14.18.1
OS
Linux
Language
Typescript
Language Version
No response
Other information
It seems that related changes were made in
3cd8d481906fc4e3abdd1211908844e5b8bd2509
commit in@aws-cdk/aws-sns-subscriptions/lib/lambda.ts
line 39.The text was updated successfully, but these errors were encountered: