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

@aws-cdk/triggers: Make it possible to configure extra payload to pass to the target lambda function #32174

Closed
1 of 2 tasks
bbmarkus opened this issue Nov 18, 2024 · 2 comments
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.

Comments

@bbmarkus
Copy link

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.

      new triggers.Trigger(this, `WorkflowTrigger`, {
        handler,
        payload: {
             workflowId: 'foobar',
        },
        invocationType: triggers.InvocationType.EVENT,
        executeAfter: [resourceA, resourceB],
      });

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 exist

This 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

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.167.1

Environment details (OS name and version, etc.)

Windows / WSL (Ubuntu)

@bbmarkus bbmarkus added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 18, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Nov 18, 2024
@bbmarkus bbmarkus changed the title aws-cdk-lib/triggers: Make it possible to configure extra properties to pass to the target lambda function aws-cdk-lib/triggers: Make it possible to configure extra payload to pass to the target lambda function Nov 18, 2024
@bbmarkus bbmarkus changed the title aws-cdk-lib/triggers: Make it possible to configure extra payload to pass to the target lambda function @aws-cdk/triggers: Make it possible to configure extra payload to pass to the target lambda function Nov 18, 2024
@github-actions github-actions bot added the @aws-cdk/triggers Related to the triggers package label Nov 18, 2024
@bbmarkus
Copy link
Author

Closing as duplicate of #19822

Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.
Projects
None yet
Development

No branches or pull requests

1 participant