From c69977b8591a29c8f9cfa0713d8452ef0f39a318 Mon Sep 17 00:00:00 2001 From: corymhall <43035978+corymhall@users.noreply.github.com> Date: Mon, 8 Nov 2021 14:41:40 +0000 Subject: [PATCH] only add dependency if topic is of type Topic --- packages/@aws-cdk/aws-sns-subscriptions/lib/lambda.ts | 2 +- packages/@aws-cdk/aws-sns-subscriptions/lib/sqs.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-sns-subscriptions/lib/lambda.ts b/packages/@aws-cdk/aws-sns-subscriptions/lib/lambda.ts index 85af9f14569c5..58c7a2aceb16b 100644 --- a/packages/@aws-cdk/aws-sns-subscriptions/lib/lambda.ts +++ b/packages/@aws-cdk/aws-sns-subscriptions/lib/lambda.ts @@ -38,7 +38,7 @@ export class LambdaSubscription implements sns.ITopicSubscription { // if the topic and function are created in different stacks // then we need to make sure the topic is created first - if (topic.stack !== this.fn.stack) { + if (topic instanceof sns.Topic && topic.stack !== this.fn.stack) { this.fn.stack.addDependency(topic.stack); } diff --git a/packages/@aws-cdk/aws-sns-subscriptions/lib/sqs.ts b/packages/@aws-cdk/aws-sns-subscriptions/lib/sqs.ts index d4e4c7cb5cc28..8bbb77927381f 100644 --- a/packages/@aws-cdk/aws-sns-subscriptions/lib/sqs.ts +++ b/packages/@aws-cdk/aws-sns-subscriptions/lib/sqs.ts @@ -63,7 +63,7 @@ export class SqsSubscription implements sns.ITopicSubscription { // if the topic and queue are created in different stacks // then we need to make sure the topic is created first - if (topic.stack !== this.queue.stack) { + if (topic instanceof sns.Topic && topic.stack !== this.queue.stack) { this.queue.stack.addDependency(topic.stack); }