Skip to content
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

topic.subscribeQueue across stacks creates a cyclic dependency #1534

Closed
eladb opened this issue Jan 13, 2019 · 2 comments · Fixed by #1645
Closed

topic.subscribeQueue across stacks creates a cyclic dependency #1534

eladb opened this issue Jan 13, 2019 · 2 comments · Fixed by #1645
Labels
@aws-cdk/aws-sns Related to Amazon Simple Notification Service @aws-cdk/aws-sqs Related to Amazon Simple Queue Service bug This issue is a bug.

Comments

@eladb
Copy link
Contributor

eladb commented Jan 13, 2019

Repro:

import cdk = require('@aws-cdk/cdk');
import sns = require('@aws-cdk/aws-sns');
import sqs = require('@aws-cdk/aws-sqs');

const app = new cdk.App();

const stackWithTopic = new cdk.Stack(app, 'stack-with-topic');
const stackWithQueue = new cdk.Stack(app, 'stack-with-queue');

const queue = new sqs.Queue(stackWithQueue, 'MyQueue');
const topic = new sns.Topic(stackWithTopic, 'MyTopic');

topic.subscribeQueue(queue);

app.run();

Error:

Stack 'stack-with-topic' already depends on stack 'stack-with-queue'. Adding this dependency would create a cyclic reference.

This is because sns.Subscription references the queue and sqs.QueuePolicy references the topic. I wonder if the right solution to this is to create the subscription in the scope of the queue and not in the scope of the topic.

@eladb
Copy link
Contributor Author

eladb commented Jan 13, 2019

@rix0rrr what do you think?

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 14, 2019

For this particular case, I think that's a pragmatic solution.

The generically correct way of dealing with these is to put the QueuePolicy into a 3rd stack (automatically), but we don't have support for that yet.

@rix0rrr rix0rrr added bug This issue is a bug. @aws-cdk/aws-sns Related to Amazon Simple Notification Service @aws-cdk/aws-sqs Related to Amazon Simple Queue Service labels Jan 17, 2019
rix0rrr pushed a commit that referenced this issue Jan 31, 2019
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.
rix0rrr added a commit that referenced this issue Feb 6, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-sns Related to Amazon Simple Notification Service @aws-cdk/aws-sqs Related to Amazon Simple Queue Service bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants