-
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
fix(sns): race condition exists between sqs queue policy and sns subscription #21259
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Construct } from 'constructs'; | ||
import { Construct, IDependable } from 'constructs'; | ||
import { SubscriptionOptions } from './subscription'; | ||
import { ITopic } from './topic-base'; | ||
|
||
|
@@ -24,6 +24,15 @@ export interface TopicSubscriptionConfig extends SubscriptionOptions { | |
* subscribing to. | ||
*/ | ||
readonly subscriberId: string; | ||
|
||
/** | ||
* The resources that need to be created before the subscription can be safely created. | ||
* For example for SQS subscription, the subscription needs to have a dependency on the SQS queue policy | ||
* in order for the subscription to successfully deliver messages. | ||
* | ||
* @default - empty list | ||
*/ | ||
readonly subscriptionDependencies?: IDependable[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're only adding one dependable here so why make it an array? Also, your logic above doesn't seem to have a scenario where subscriptionDependencies is undefined so I'm not sure why this would be optional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made it an array to make it generic, but I guess it's not backwards incompatible to change this in the future to a list if needed. It needs to be undefined because only the SQS subscription needs to set this, the lambda and email subscription don't need this: https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sns-subscriptions/lib/email.ts, https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sns-subscriptions/lib/sms.ts, https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sns-subscriptions/lib/lambda.ts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really see any value to make it an array when we only expect one value here. It's adding unnecessary logic elsewhere. |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're setting this a few lines above. Under what conditions would this not be defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not defined if the queue is imported or if
autoCreatePolicy
is set to false while no queue policy exists: https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sqs/lib/queue-base.ts#L144