Is it feasible to achieve what I'm attempting, or am I starting with an impossible task?
When a Event Bridge Rule is triggered by an added event pattern, like shown below, should the detailed information be included in the step input?
const rule = new Rule(this, 'Rule', {
schedule: Schedule.expression('cron(0 18 ? * SUN-WED *)'),
}
rule.addEventPattern({
detail: {
example: [
'hello-world',
],
},
});
rule.addTarget(new SfnStateMachine(stateMachine));
Currently, only limited step input is displayed. What could be missing if this doesn't work as expected?
{
"version": "0",
"id": "590c8f79-8bb5-d50b-30f7-1234567890",
"detail-type": "Scheduled Event",
"source": "aws.events",
"account": "1234567890",
"time": "2022-01-14T19:33:47Z",
"region": "eu-west-1",
"resources": [
"arn:aws:events:eu-west-1:1234567890:rule/Example-Rule4C995B7F-UJ68BG8LJK54"
],
"detail": {}
}
Update: Thanks to Fedonev's guidance, I was able to make it work as follows;
rule.addTarget(new SfnStateMachine(stateMachine, {
input: RuleTargetInput.fromObject({
'version': 'custom',
'id': EventField.fromPath('$.id'),
'detail-type': EventField.fromPath('$.detail-type'),
'source': EventField.fromPath('$.source'),
'account': EventField.fromPath('$.account'),
'time': EventField.fromPath('$.time'),
'region': EventField.fromPath('$.region'),
'resources': EventField.fromPath('$.resources'),
'detail': {
example: [
'hello-world',
],
},
}),
}));