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-events-targets): (Add support for Predefined variables for Input transformers) #27841

Open
2 tasks
luisMolina95 opened this issue Nov 5, 2023 · 0 comments
Open
2 tasks
Labels
@aws-cdk/aws-events-targets effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@luisMolina95
Copy link

luisMolina95 commented Nov 5, 2023

Describe the feature

Currently there is no available feature to make use of Predefined variables.

AWSEventField would work the same way as EventField but for the AWS Predefined variables ( aws.events.rule-arn, aws.events.event.json, aws.events.rule-name, aws.events.event.ingestion-time, aws.events.event ).

Use Case

Without Predefined variables available in CDK, we need to keep deploying changes to the input transformer, and keep manually adding attributes with RuleTargetInput.

When we could instead just use aws.events.event.json to add the original event and then add the additional metadata but rigth now there is no option to use Predefined variables at all.

Proposed Solution

For example this code:

import { RuleTargetInput, AWSEventField } from "aws-cdk-lib/aws-events";

const ruleTargetInput = RuleTargetInput.fromObject({
      // Currently this does not work,  it is configured as a Constant rather than as an Input Transformer.
      // ruleName: "<aws.events.rule-name>",
      // originalEvent: "<aws.events.event.json>",
      // This new feature would make it possible:
      ruleName: AWSEventField.ruleName,
      originalEvent: AWSEventField.eventJSON ,
    });

Would generate the following stack template (an empty object input map and an input template with only Predefined variables):

{
  "Arn": {
    "Fn::GetAtt": ["function", "Arn"]
  },
  "Id": "Target0",
  "InputTransformer": {
    "InputPathsMap": { },
    "InputTemplate": "{\"ruleName\":<aws.events.rule-name>,\"originalEvent\":<aws.events.event.json>}"
  }
}

Other Information

https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html#eb-transform-input-predefined

Acknowledgements

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

CDK version used

2.104.0

Environment details (OS name and version, etc.)

Windows 10

@luisMolina95 luisMolina95 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 5, 2023
@khushail khushail added needs-review p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. needs-review labels Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-events-targets effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants