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

Race condition between SQS QueuePolicy and SNS Subscription #20665

Closed
jonnekaunisto opened this issue Jun 8, 2022 · 4 comments · Fixed by #21797
Closed

Race condition between SQS QueuePolicy and SNS Subscription #20665

jonnekaunisto opened this issue Jun 8, 2022 · 4 comments · Fixed by #21797
Assignees
Labels
@aws-cdk/aws-sns-subscriptions bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@jonnekaunisto
Copy link
Contributor

Describe the bug

For the SqsSubscription currently the QueuePolicy can get deployed before or after the Subscription. If the queue policy deploys afterwards, it will cause failures to send messages from SNS to SQS.

Expected Behavior

QueuePolicy will deploy before Subscription.

Current Behavior

QueuePolicy can sometimes deploy after Subscription.

Reproduction Steps

Create a SqsSubscription and it will generate a template where there is no dependency between the Queue Policy and Subscription.

Possible Solution

Not sure how, the code for this is complicated since the queue is passed into this: https://github.com/aws/aws-cdk/blob/v1.159.0/packages/@aws-cdk/aws-sns-subscriptions/lib/sqs.ts#L35

but the subscription is created here: https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sns/lib/topic-base.ts#L80

Additional Information/Context

No response

CDK CLI Version

3

Framework Version

No response

Node.js Version

16

OS

Mac OS

Language

Typescript

Language Version

No response

Other information

No response

@jonnekaunisto jonnekaunisto added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 8, 2022
@peterwoodworth peterwoodworth changed the title aws-sns-subscriptions: Add AWS::SQS::QueuePolicy as a dependency of AWS::SNS::Subscription Race condition between SQS QueuePolicy and SNS Subscription Jun 9, 2022
@peterwoodworth peterwoodworth added good first issue Related to contributions. See CONTRIBUTING.md p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 9, 2022
@peterwoodworth
Copy link
Contributor

Thanks for reporting this @jonnekaunisto!

I'll try to look more into this later to see if I can confirm this is happening, and then would provide a fix if possible. But I or someone else on the team may not be able to get to this soon - in that case we accept contributions!

@peterwoodworth peterwoodworth self-assigned this Jun 9, 2022
@jonnekaunisto
Copy link
Contributor Author

I would be happy to contribute. But I think there are 2 issues that need to be solved first.

  1. How do we get access to the queue in the addSubscription function? The queue is accessible through the subscriberScope, but is it ok to have dual meaning for that field?
  2. How do we get access to the queue policy, since it is a private field? Can we just make this public? You can already technically access this by calling addToResourcePolicy.

@jonnekaunisto
Copy link
Contributor Author

jonnekaunisto commented Jun 21, 2022

Any thoughts on the above @peterwoodworth @kaizencc?

@kaizencc kaizencc removed the good first issue Related to contributions. See CONTRIBUTING.md label Jun 23, 2022
@kaizencc kaizencc removed their assignment Jun 23, 2022
@mergify mergify bot closed this as completed in #21797 Oct 2, 2022
mergify bot pushed a commit that referenced this issue Oct 2, 2022
…cription (#21797)

----

Fixes #20665 by adding a dependency to sqs policy for sns subscriptions.
### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*


This is a follow up to #21259, which got closed for failing for too long
@github-actions
Copy link

github-actions bot commented Oct 2, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

arewa pushed a commit to arewa/aws-cdk that referenced this issue Oct 8, 2022
…cription (aws#21797)

----

Fixes aws#20665 by adding a dependency to sqs policy for sns subscriptions.
### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*


This is a follow up to aws#21259, which got closed for failing for too long
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-sns-subscriptions bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
3 participants