I have a lambda function that gets invoked with an...
# aws
q
I have a lambda function that gets invoked with an event trigger every x minutes. In Pulumi, I was able to set up the lambda function with event rule and event target, but I can’t seem to figure out how I can configure the
trigger
. Maybe I’m missing something in the docs… does anyone have any idea that can help me out here?
l
It's probably a CloudWatch event rule? I think schedule triggers for lambdas are usually event rules.
There's some magic in the AWS console that creates them for you. When using Pulumi or similar tools, you have to do it yourself.
To confirm in the AWS console, you can view your lambda. My scheduled lambdas say that the trigger is "EventBridge (CloudWatch Events)".
q
Yes I can create it manually in the AWS console but I really need to do it through Pulumi, just couldn’t find out how I can do it when I create
EventRule
or
EventTarget
via pulumi. Thought I could be missing something obvious that someone can point out.
@little-cartoon-10569 Is your trigger set up via Pulumi?
l
Yes. I use
aws.cloudwatch.EventRule
to define the schedule, and its
onEvent()
mixin to hook it up to the lambda handler function.
I believe there are other ways to achieve the same thing.
q
Ahh I think the
onEvent()
is what I’m missing. Thanks heaps, I’ll look into that
l
Ah yes. They're not well documented. I haven't ever found them on pulumi.com. I think I got a hint from this Slack, then looked through the source code to figure them out.
👍 1
onEvent()
is defined in
@pulumi/aws/cloudwatch/eventRuleMixins.d.ts
, if you're using TypeScript.
q
That’s perfect, thanks 😄
👍 1