How do I use Predefined variables in an Input transformer with CDK? #27833
Answered
by
luisMolina95
luisMolina95
asked this question in
Q&A
-
My goal is for CDK to generate this template: {
"Arn": {
"Fn::GetAtt": [
"",
"Arn"
]
},
"Id": "",
"InputTransformer": {
"InputPathsMap": { },
"InputTemplate": "{\"ruleName\":<aws.events.rule-name>,\"originalEvent\":<aws.events.event.json>}"
}
} I am trying this: const Rule = new Rule(this, "ruleName", {
eventBus,
eventPattern: { },
targets: [
new LambdaFunction(lambda, {
event: RuleTargetInput.fromObject({
ruleName:EventField.fromPath("aws.events.rule-name"),
originalEvent: EventField.fromPath("aws.events.rule-name"),
}),
}),
],
}); But i am getting this instead: {
"Arn": {
"Fn::GetAtt": [
"",
"Arn"
]
},
"Id": "",
"InputTransformer": {
"InputPathsMap": {
"aws-events-rule-name": "aws.events.rule-name",
"aws-events-event-json": "aws.events.event.json",
},
"InputTemplate": "{\"ruleName\":<aws-events-rule-name>,\"originalEvent\":<aws-events-event-json>}"
}
} Is it possible to use Predefined variables on CDK? |
Beta Was this translation helpful? Give feedback.
Answered by
luisMolina95
Nov 8, 2023
Replies: 2 comments
-
This is my workaround, be aware that this does not work for const inputTransformerEvent = RuleTargetInput.fromObject({
ruleName: "<aws.events.rule-name>",
originalEvent: EventField.fromPath("$"),
}); {
"Arn": {
"Fn::GetAtt": [
"",
"Arn"
]
},
"Id": "",
"InputTransformer": {
"InputPathsMap": {
"f1": "$"
},
"InputTemplate": "{\"ruleName\":\"<aws-events-rule-name>\",\"originalEvent\":<f1>}"
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
luisMolina95
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my workaround, be aware that this does not work for
aws.events.event.json
and that if you removeEventField.fromPath("$")
it becomes a contant instead of an input transform.