-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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-destinations): option to auto-extract the payload when using LambdaDestination #5503
Conversation
Add a `LambdaChain` construct to chain asynchronous invocations of Lambda functions. Asynchronously invoking the first function starts the execution chain. The response payload of a successful invocation of a function in the chain is passed as request payload to the next function automatically using EventBridge. Allows to start a series of long running processes. The poor man's step function?
Does it fit in here (cdk)? Maybe something for |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
This is an interesting pattern Jonathan.
CDK packages will always carry constructs that abstract away the CloudFormation resource constructs (i.e., Cfn*
). Beyond this, we would also carry patterns that we think are of high demand or highly common to CDK customers. We've drawn this line based on the cost of ownership and maintenance.
I suggest that you could perhaps maintain and publish your own CDK patterns module, of which this could be the first. When this is ready, we'll be totally happy to accept a PR which adds a link to your module into lambda module's README under a new section called something like 'Related Projects'.
Perfectly get that and I agree that this PR goes a bit too far here. This was anyway fun to develop. Rest assured that I don't take this personally of course.
Had also this discussion with @eladb yesterday. Not sure I have time to do this right now, but noted! |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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 am wondering about LambdaPayloadDestination
... Would it make sense to hide this behind an option of LambdaDestination
instead of introducing another destination type?
OK. Any ideas for the name of this option? |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
LGTM, @nija-at ?
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 |
@nija-at improved README, JSDoc and integ test. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
* For EventBridge, the JSON is passed as the `Detail` in the PutEvents call. The source is `lambda`, | ||
and detail type is either `Lambda Function Invocation Result - Success` or `Lambda Function Invocation Result – Failure`. | ||
The resource fields contain the function and destination ARNs. | ||
|
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.
Can you add a couple of sentences here on how all this connects to the CDK? As in, when a customer connects SqsDestination
, LambdaDestination
, etc., what should they expect as the sqs message, the lambda payload, etc.?
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.
- For SNS/SQS, the invocation record JSON is passed as the
Message
to the destination.- For Lambda, the invocation record JSON is passed as the payload to the function.
- For EventBridge, the invocation record JSON ...
Isn't this the same?
Maybe like this?
- For SNS/SQS (
SnsDestionation
/SqsDestination
), the invocation record JSON is passed as theMessage
to the destination. - For Lambda (
LambdaDestination
), the invocation record JSON is passed as the payload to the function. - For EventBridge (
EventBridgeDestination
), the invocation record JSON ...
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.
Ah yes, that should be good enough.
Co-Authored-By: Niranjan Jayakar <16217941+nija-at@users.noreply.github.com>
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 |
Thank you for contributing! Your pull request is now being automatically merged. |
Add option to send only the response payload when using
LambdaDestination
.When set to
true
, the default event bus is set as destination and a rulethat extracts the payload triggers the destination function.
This allows to easily "chain" Lambda functions without having to deal with the
event format in the runtime code.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license