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

quiet-umbrella-96481

09/07/2021, 5:43 AM
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

little-cartoon-10569

09/07/2021, 5:51 AM
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

quiet-umbrella-96481

09/07/2021, 5:55 AM
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

little-cartoon-10569

09/07/2021, 5:58 AM
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

quiet-umbrella-96481

09/07/2021, 5:58 AM
Ahh I think the
onEvent()
is what I’m missing. Thanks heaps, I’ll look into that
l

little-cartoon-10569

09/07/2021, 5:59 AM
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

quiet-umbrella-96481

09/07/2021, 6:00 AM
That’s perfect, thanks 😄
👍 1