https://pulumi.com logo
#aws
Title
a

abundant-appointment-96790

12/16/2020, 6:55 AM
Hi all! Is there anyway to hook a lambda function with a Cloudwatch Event rule that returns a static JSON? The
EventRule.onEvent
doesn’t seem to support customize the payload and only support the default one. More info: EventRule -> SQS: you can use 
new aws.cloudwatch.EventTarget
 and it will emit a static JSON to the SQS queue. When I tried to do the same thing for Lambda, passing the Lambda ARN into 
aws.cloudwatch.EventTarget
 , the Lambda triggered is not created (presumably because EventSourceMapping is not created underneath). The only way to hook an 
EventRule
 to a Lambda is to call: 
EventRule.onEvent
. But that doesn’t let me configure the payload (code linked in the comment)
f

faint-table-42725

12/16/2020, 7:03 AM
I’m not quite sure I understand what you’re trying to do. I didn’t think EventRules actually listened to the reply from a lambda invocation?
a

abundant-appointment-96790

12/16/2020, 4:29 PM
So EventRule -> SQS: you can use
new aws.cloudwatch.EventTarget
and it will emit a static JSON to the SQS queue. When I tried to do the same thing for Lambda, passing the Lambda ARN into
aws.cloudwatch.EventTarget
, the Lambda triggered is not created (presumably because EventSourceMapping is not created underneath). The only way to hook an
EventRule
to a Lambda is to call:
EventRule.onEvent
. But that doesn’t let me configure the payload: https://github.com/pulumi/pulumi-aws/blob/master/sdk/nodejs/cloudwatch/eventRuleMixins.ts#L129 This only lets me connect an EventRule to a Function and the payload will have this schema: https://github.com/pulumi/pulumi-aws/blob/master/sdk/nodejs/cloudwatch/eventRuleMixins.ts#L29