AWS

How to Trigger AWS Lambda Using AWS EventBridge

Triggers in AWS Lambda are configured to invoke the Lambda functions in specific events and conditions with the help of other AWS services. The AWS EventBridge is one of the services that can trigger the lambda functions. It provides real-time access to the changes in AWS Lambda functions. A single AWS Lambda function can have multiple triggers, so, there is no limit to the number of triggers a lambda function can have.

In this article, we will discuss how to trigger the Lambda function through the AWS EventBridge service.

How to Trigger AWS Lambda With EventBridge?

To trigger the lambda function, we need first to create a function in AWS Lambda if there is no existing lambda function.

Select AWS Lambda from the AWS services after logging in to the AWS Management Console. After opening the AWS lambda interface, click on the “Create function” button:

Type a name for the function and configure the other settings like runtime language and architecture. Here, we proceed with the default settings:

Click on the “Create function” button:

In this way, the function is created, and the newly created function appears in the list of lambda functions. Click on the name of the function to view its details:

There will be an option to “Add trigger” to the lambda function, simply click on that:

Now, the user is supposed to add an AWS service from the displayed dropdown menu as the source to trigger the function:

For this post, we will trigger the function through the CloudWatch EventBridge service. To do that, simply search for the “EventBridge” and select it:

After selecting the EventBridge service as a source, the user has to either create a new rule or select an existing one that will contain the configurations according to which the function will be invoked. Here, we will create a new rule for further elaboration. Simply select the “Create a new rule” option and type a name for the rule:

While configuring the rule for the “EventBridge (CloudWatch Event)” trigger, the user is supposed to select either “Event pattern” or “Schedule expression” as the rule type.

The difference between the two is that “Event pattern” consists of a series of events occurring in a particular way, and “Schedule expression” asks the user to enter the time limit after which the function should be invoked.

For this post, we select the “Schedule expression” option and then set the time limit as 1 minute, and click on the “Add” button:

After that, the trigger will appear in the details of the AWS Lambda function:

This was all about how to trigger the AWS Lambda using the AWS EventBridge service.

Conclusion

AWS Lambda is triggered to invoke the lambda functions through other AWS services. The option to add the trigger is present in the AWS Lambda service in details of the created function through which the user can connect the lambda function to other services like AWS EventBridge and define and configure the rules for invoking the functions according to the nature of service selected as the source.

About the author

Hadia Atiq

A Software Engineer and Technical Writer passionate about learning and spreading knowledge of the latest technology. I utilize my writing skills to help readers understand the importance and usage of modern technology.