Member-only story

CloudFormation: EventBridge integration with Lambda

Fahim Fahad
AWS in Plain English
3 min readJun 3, 2023

CloudFormation is an AWS service that enables developers to create AWS resources easily, allowing us to reuse the scripts to create resources.

In this article, I will use CloudFormation to create an EventBridge rule that will trigger periodically to publish some data to a Lambda function. I will use a simple lambda just to print the request that we received from EventBridge. Lets begin 🙂

Script

AWSTemplateFormatVersion: '2010-09-09'
Description: >-
CloudFormation template to integrate EventBridge rule with Lambda
Resources:
EventRule1:
Type: AWS::Events::Rule
Properties:
EventBusName: default
Name: test-eb-rule-for-every-3-min
ScheduleExpression: cron(0/3 * * * ? *)
State: ENABLED
Targets:
- Id: test-eb-rule-1-for-every-3-min
Arn: >-
arn:aws:lambda:us-east-1:568560058349:function:fahim-test
Input: |-
{
"body": {
"type": "test"
}
}
PermissionForEvent0ToInvokeLambda:
Type: AWS::Lambda::Permission
Properties:
FunctionName: fahim-test
Action: "lambda:InvokeFunction"
Principal: "events.amazonaws.com"
SourceArn:
Fn::GetAtt:
- "EventRule1"
- "Arn"

This is a simple script. We only need a few things to make this work. The first one is the lambda function name and function arn that we will use in the Targets section. In the input section, we…

Published in AWS in Plain English

New AWS, Cloud, and DevOps content every day. Follow to join our 3.5M+ monthly readers.

Responses (1)

What are your thoughts?

Absolute lifesaver, thank you for writing this up! Saved me heaps of time