-
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
feat(lambda): sns topic dlq #4763
Conversation
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
@@ -1387,6 +1387,11 @@ acorn-globals@^4.1.0: | |||
acorn "^6.0.1" | |||
acorn-walk "^6.0.1" | |||
|
|||
acorn-jsx@^5.1.0: |
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.
Not sure where the huge diff in the yarn.lock
is coming from. I can revert it if necessary
* | ||
* @default - no dead-letter queue will be used or created | ||
*/ | ||
readonly dlq?: DeadLetterQueue; |
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.
I'm not a fan of dlq
as a property name. The "queue" part isn't even true anymore. How about deadLetter
? Same for the class, DeadLetter
?
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.
Use deadLetterTarget
and DeadLetterTarget
; consistent with the name Lambda has given it - https://docs.aws.amazon.com/lambda/latest/dg/API_DeadLetterConfig.html
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
/** | ||
* Describes the type of resource to use as a Lambda dead-letter queue | ||
*/ | ||
enum DeadLetterQueueType { |
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.
Not sure how to please JSII on this one. I've tried:
export
with@internal
export
- no
export
None of which build successfully
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.
@eladb Any idea what to do about that?
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.
We ship enums in the CDK - https://github.com/aws/aws-cdk/search?l=TypeScript&q=enum. What's the problem?
*/ | ||
// tslint:disable-next-line:ban-types | ||
public bind(fn: Function) { | ||
switch (this.type) { |
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.
Instead of this, just make bind
abstract and implement it in-place for each fromXxx
method:
export abstract class DeadLetterQueue {
public static fromSqsQueue(queue?: sqs.IQueue): DeadLetterQueue {
return {
bind: fn => { /* code for SQS queue */ }
};
}
public static fromSnsTopic(topic?: sns.ITopic): DeadLetterQueue {
return {
bind: fn => { /* code for SNS */ }
}
public abstract bind(fn: lambda.Function): void;
}
@@ -110,7 +115,7 @@ const fn = new lambda.Function(this, 'MyFunction', { | |||
runtime: lambda.Runtime.NODEJS_8_10, | |||
handler: 'index.handler', | |||
code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'), | |||
deadLetterQueueEnabled: true | |||
dlq: lambda.DeadLetterQueue.fromSqsQueue(), |
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.
I think that in this case the from
prefix doesn't feel right because we allow no parameters and so "from what?". I'd argue that lambda.DeadLetterQueue.sqsQueue()
reads better in this case and cal also accomnodate DeadLetterQueue.sqsQueue(x)
(@rix0rrr, thoughts?).
Alternatively we can do: fromNewQueue()
and fromQueue(x)
.
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.
Refer to comments from Elad and the failing build.
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
5 similar comments
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Closing this for now, since there's no activity on here for 2 months. Feel free to re-open and pick this back up when ready. |
dlq
property, withDeadLetterQueue
helper classDeadLetterQueue.fromSnsTopic
featuredeadLetterQueue
anddeadLetterQueueEnabled
propsFixes #2739
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license