@aws-cdk/triggers: Make it possible to configure extra payload to pass to the target lambda function #32174
Closed
1 of 2 tasks
Labels
@aws-cdk/aws-lambda
Related to AWS Lambda
@aws-cdk/triggers
Related to the triggers package
feature-request
A feature should be added or improved.
needs-triage
This issue or PR still needs to be triaged.
Describe the feature
We would like to enable re-use of trigger handler functions by having a way to pass extra properties through the custom resource
created by the trigger and then pass them to the final target lambda as part of its event object payload.
Use Case
Ability to re-use trigger targets, e.g. when trigger target makes an API call to external 3rd party REST API which then needs something related to the trigger's dependent resources as its input.
This re-use would be helpful when a stack has multiple similar resources deployed that we need to poke an external system about. For example a stack with S3 buckets, when we can use this lambda to tell an external system the bucket is ready to be populated.
Proposed Solution
An API change for
Trigger
to allow passing extra properties to the custom resource, which then the handler would pass on to the actual trigger target as the payload when invoking the function. Below is a pseudo code example.Other Information
We could most likely relatively easily trigger a lambda with
AwsCustomResource
skipping the intermediate lambda of the Trigger construct entirely and it would serve our current use case quite well, but it feels like a kludge. We could also have the deployment create a custom resource that pushes a custom event to an event bus with the lambda as a target for those events, but this feels equally roundabout when Triggers existThis request is opened mainly because it feels silly that the only apparent way to parametrize trigger targets is with environment variables (unless I missed something while digging through the current implementation) which effectively prevents re-using the target lambda.
Acknowledgements
CDK version used
2.167.1
Environment details (OS name and version, etc.)
Windows / WSL (Ubuntu)
The text was updated successfully, but these errors were encountered: