{"id":488,"date":"2025-09-12T05:21:02","date_gmt":"2025-09-12T05:21:02","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=488"},"modified":"2025-09-12T05:21:02","modified_gmt":"2025-09-12T05:21:02","slug":"trigger-aws-lambda-function-using-event-bridge-rule","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=488","title":{"rendered":"How to Trigger an AWS Lambda Function using an Event Bridge Rule?"},"content":{"rendered":"<p>In this guide, we will build an event-driven architecture using AWS EventBridge and AWS Lambda. <\/p>\n<p>You will learn how to create an EventBridge rule that automatically triggers a Lambda function. As an example, we will use a cron expression to fetch S3 object details<\/p>\n<p>At the end of this blog, you will have learned<\/p>\n<ol>\n<li>Create an EventBridge Rule<\/li>\n<li>Create a AWS Lambda function<\/li>\n<li>Trigger the Lambda function using the EventBridge Rule<\/li>\n<\/ol>\n<p>Before we move to the setup, you need to know what the <strong>AWS Lambda service<\/strong> and the <strong>AWS EventBridge service<\/strong> are.<\/p>\n<h2 id=\"what-is-aws-eventbridge\">What is AWS EventBridge?<\/h2>\n<p>AWS EventBridge is a fully managed serverless event bus that lets you create custom events like cron expressions or capture events from AWS services and external applications. <\/p>\n<p>These events can then be <strong>routed to targets<\/strong> like Lambda, SQS, or SNS<\/p>\n<p>For example, if an EC2 instance goes down, EventBridge can automatically capture the event and send an email to the respective team.<\/p>\n<p>It also helps in,<\/p>\n<ul>\n<li>Generating reports<\/li>\n<li>Periodical backups or cleanup<\/li>\n<li>Running maintenance tasks<\/li>\n<\/ul>\n<h2 id=\"what-is-aws-lambda\">What is AWS Lambda?<\/h2>\n<p>AWS Lambda is a serverless service where we can directly run our code without managing the servers.<\/p>\n<p>To run our code, we can manually trigger the function or use any automatic trigger, such as an event from another service.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\">EventBridge with Lambda is mainly used for <b><strong style=\"white-space: pre-wrap;\">asynchronous<\/strong><\/b> workflows, which means that EventBridge triggers the Lambda function, but will not wait for any response from the Lambda.<\/div>\n<\/div>\n<p>If you are new to AWS Lambda, check out our simple blog to <a href=\"https:\/\/devopscube.com\/serverless-framework-tutorial\/\">deploy serverless framwork on AWS Lambda<\/a>.<\/p>\n<p>Now, we can see the overview of the setup workflow.<\/p>\n<h2 id=\"eventbridge-lambda-workflow\">EventBridge + Lambda Workflow<\/h2>\n<p>The following is the workflow diagram of the integration of AWS EventBridge and Lambda.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-49.png\" class=\"kg-image\" alt=\"EventBridge + Lambda Workflow\" loading=\"lazy\" width=\"684\" height=\"456\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-49.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-49.png 684w\"><\/figure>\n<p>Here is how the workflow looks.<\/p>\n<ol>\n<li>The EventBridge Rule is created to trigger the Lambda function on a periodic interval.<\/li>\n<li>An EventBridge Rule is attached to an IAM Role to access the Lambda.<\/li>\n<li>Once the event is triggered, the Lambda function will activate and run the script.<\/li>\n<li>Lambda function is attached with the <a href=\"https:\/\/devopscube.com\/aws-iam-role-instance-profile\/\" rel=\"noreferrer\">IAM Role<\/a> to access specific AWS services (e.g., S3, <a href=\"https:\/\/devopscube.com\/how-to-setup-and-push-serverapplication-logs-to-aws-cloudwatch\/\" rel=\"noreferrer\">CloudWatch<\/a>)<\/li>\n<li>During the execution, metrics and logs will be stored in CloudWatch so that we can monitor them.<\/li>\n<\/ol>\n<p>Now, we can start the setup.<\/p>\n<h2 id=\"setup-prerequisites\">Setup Prerequisites<\/h2>\n<p>To achieve this setup, we need the following requirements.<\/p>\n<ol>\n<li>AWS Account &#8211; Required permission to create and manage services<\/li>\n<li><a href=\"https:\/\/devopscube.com\/use-aws-cli-create-ec2-instance\/\" rel=\"noreferrer\">AWS CLI<\/a>, [Local Workstation]<\/li>\n<\/ol>\n<p>Now, we can start the setup by creating a Lambda Function.<\/p>\n<h2 id=\"creating-a-lambda-function\">Creating a Lambda Function<\/h2>\n<p>To begin the setup, you need to open the Lambda service and, from the home page, click the <code>Create a function<\/code> button to create a function.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-1.png\" class=\"kg-image\" alt=\"The console page of the AWS lambda\" loading=\"lazy\" width=\"780\" height=\"643\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-1.png 780w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>On the function creation page, select the option of <code>Author from scratch<\/code> to create your own function, give a name to the function, and select a runtime where you are comfortable to write scripts.<\/p>\n<p>For this, I am choosing the <a href=\"https:\/\/devopscube.com\/python-for-devops\/\" rel=\"noreferrer\">Python<\/a> 3.13 runtime, and I am keeping the rest of the configuration as the default.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-2.png\" class=\"kg-image\" alt=\"the function creation page of the aws lambda\" loading=\"lazy\" width=\"1732\" height=\"1320\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-2.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-2.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/08\/image-2.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-2.png 1732w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>When scrolling down, you can see a section to create an IAM Role for your Lambda function. <\/p>\n<p>This IAM Role defines the permissions of which AWS services that the Lambda can access.<\/p>\n<p>For example, if I write a script for Lambda to list S3 buckets, it needs the required permission to access the S3.<\/p>\n<p>So in the execution role section, I am selecting  &#8220;Create a new role with basic Lambda permissions&#8221; to create a Role.<\/p>\n<p>But if you already have an existing role with the necessary permissions, you can use that as well.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/09\/image-4.png\" class=\"kg-image\" alt=\"The iam role creation page of the lambda function\" loading=\"lazy\" width=\"1045\" height=\"351\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/09\/image-4.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/09\/image-4.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/09\/image-4.png 1045w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>On the same page, you can also configure networking and Encryption using KMS. You can configure them if required.<\/p>\n<p>The basic IAM Role will have permission to <strong>CloudWatch<\/strong> to write the Lambda logs, but we need to add the <strong>S3<\/strong> permission on this Role.<\/p>\n<p>Once the role creation is completed, open the created IAM Role and add the S3 permission.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/09\/image-5.png\" class=\"kg-image\" alt=\"the added permission for s3 in iam role for the lambda function\" loading=\"lazy\" width=\"837\" height=\"653\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/09\/image-5.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/09\/image-5.png 837w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Now, we have our IAM Role ready for the Lambda function with required permission.<\/p>\n<p>Once the function is created, you will reach a page similar to the following one.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-4.png\" class=\"kg-image\" alt=\"the home page of the aws lambda function\" loading=\"lazy\" width=\"1492\" height=\"1196\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-4.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-4.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-4.png 1492w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Now, we need to configure the Function code.<\/p>\n<p>For demo, I am adding a Boto3 script to list the S3 buckets and their object details. <\/p>\n<pre><code class=\"language-python\">import boto3\n\n# This script lists all S3 buckets and their objects using the Boto3 library in Python.\ns3 = boto3.client('s3')\n\nlist_buckets = s3.list_buckets()\n\nbucket_names = [bucket['Name'] for bucket in list_buckets['Buckets']]\nfor bucket in bucket_names:\n    print(bucket)    \n\ndef list_objects_in_bucket():\n    list_objects = s3.list_objects(\n        Bucket = source_bucket\n    )\n    if 'Contents' in list_objects:\n        for obj in list_objects['Contents']:\n            print(f\"Object: {obj['Key']}, Last Modified: {obj['LastModified']}, Size: {obj['Size']} bytes\")\n    else:\n        print(\"No objects found in the bucket.\")\n\nfor source_bucket in bucket_names:\n    print(f\"Source Bucket: {source_bucket}\")\n    list_objects_in_bucket()\n<\/code><\/pre>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-46.png\" class=\"kg-image\" alt=\"the code section of the aws lambda function\" loading=\"lazy\" width=\"1048\" height=\"735\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-46.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-46.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-46.png 1048w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Now, we need to create an event to trigger this lambda function automatically.<\/p>\n<h2 id=\"configuring-aws-eventbridge-rule\">Configuring AWS EventBridge Rule<\/h2>\n<p>We are now selecting one specific configuration in EventBridge.<\/p>\n<p>We will create a Rule with a scheduling expression to define how often it should run.<\/p>\n<p>In our case, the Rule will periodically (e.g., every 5 min) trigger the Lambda function that we created in the previous step.<\/p>\n<p>Open the EventBridge service from the console, select the rules section, and click <code>Create rule<\/code> to configure a rule.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-6.png\" class=\"kg-image\" alt=\"the rule creation page of the aws event bridge\" loading=\"lazy\" width=\"2000\" height=\"975\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-6.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-6.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/08\/image-6.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-6.png 2256w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>On the first page, give a name to the rule and select the rule type as <code>Schedule<\/code><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-7.png\" class=\"kg-image\" alt=\"the defining rule details page of the aws event bridge\" loading=\"lazy\" width=\"2000\" height=\"1095\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-7.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-7.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/08\/image-7.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-7.png 2144w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>On the next page, you will see two schedule patterns, which are &#8220;One time schedule&#8221; and &#8220;Recurring schedule&#8221;.<\/p>\n<p>We select the recurring schedule to configure the cron expression.<\/p>\n<p>Unlike the regular cronjob, EventBridge cron expression has an additional field to add the year.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-8.png\" class=\"kg-image\" alt=\"the schedule pattern page of the aws event bridge\" loading=\"lazy\" width=\"2000\" height=\"1338\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-8.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-8.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/08\/image-8.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-8.png 2138w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Also, choose the flexible time window option to &#8220;Off&#8221;, but if you want, set when the EventBridge rule should start.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/09\/image-6.png\" class=\"kg-image\" alt=\"The flexible time window setting of the aws event bridge rule\" loading=\"lazy\" width=\"574\" height=\"365\"><\/figure>\n<p>There are additional configurations, such as timeframes, that you can configure if required. For now, we are keeping the rest of the configurations as default values.<\/p>\n<p>On the next page, you need to select the <strong>target.<\/strong> In our case, it is <strong>Lambda<\/strong>. Once you select Lambda, you will get a list to select the Lambda function.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-10.png\" class=\"kg-image\" alt=\"The target selection page of the aws eventbridge rule\" loading=\"lazy\" width=\"1386\" height=\"769\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-10.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-10.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-10.png 1386w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>On the next page, you can configure the settings, such as scheduling state, after completion action, retry policy, encryption, and permissions. You can customize them if required.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-11.png\" class=\"kg-image\" alt=\"the settings page of the aws eventbridge rule\" loading=\"lazy\" width=\"1670\" height=\"846\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-11.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-11.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/08\/image-11.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-11.png 1670w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>On the last page, you can review all the configurations that you have given, and then schedule the rule. <\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-12.png\" class=\"kg-image\" alt=\"the review page of the aws eventbridge rule\" loading=\"lazy\" width=\"2000\" height=\"1147\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-12.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-12.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/08\/image-12.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-12.png 2100w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"testing-the-setup\">Testing the Setup<\/h2>\n<p>Let&#8217;s wait a few minutes to trigger the first event. Once the event is triggered, the metrics and logs will be stored in CloudWatch.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-13.png\" class=\"kg-image\" alt=\"the metrics page of the aws lambda function\" loading=\"lazy\" width=\"991\" height=\"646\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-13.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-13.png 991w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>To see the logs, scroll down the page where you can see the execution logs.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-14.png\" class=\"kg-image\" alt=\"the cloudwatch log section of the aws lambda function\" loading=\"lazy\" width=\"934\" height=\"300\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-14.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-14.png 934w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Clicking the log stream will show you the execution steps.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-50.png\" class=\"kg-image\" alt=\"the log events of the executed lambda function\" loading=\"lazy\" width=\"1142\" height=\"468\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-50.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/08\/image-50.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-50.png 1142w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>This ensures that the EventBridge Rule is triggering the Lambda function. You can extend this with your use cases like, send this report as an email using SES.<\/p>\n<h2 id=\"cleanup-the-setup\">Cleanup the Setup<\/h2>\n<p>Now, we can start the cleanup process <\/p>\n<p>Let&#8217;s start by disabling the event and deleting the rule from the EventBridge<\/p>\n<p>Disabling the event will not trigger the lambda function, so if we need it again, we can enable it again.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-16.png\" class=\"kg-image\" alt=\"the disabling section of the aws eventbridge rule\" loading=\"lazy\" width=\"843\" height=\"306\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-16.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-16.png 843w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Now, we can delete the event rule.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-17.png\" class=\"kg-image\" alt=\"deleting the exising aws eventbridge rule\" loading=\"lazy\" width=\"836\" height=\"299\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-17.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-17.png 836w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Once the EventBridge Rule is deleted, we can delete the Lambda function.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-18.png\" class=\"kg-image\" alt=\"deleting the exising aws lambda function\" loading=\"lazy\" width=\"943\" height=\"410\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/08\/image-18.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/08\/image-18.png 943w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Now, we have cleaned up the entire setup.<\/p>\n<h2 id=\"devops-use-cases\">DevOps Use cases<\/h2>\n<p>Following are some of the key DevOps use cases for EventBridge in enterprise environments.<\/p>\n<ol>\n<li>Organizations with many AWS accounts (for dev, test, prod etc) send audit logs (e.g. IAM changes, ECR image deletions) from all accounts into a central EventBridge event bus. Then filter the events to to catch suspicious events and send alerts<\/li>\n<li>You can also ingest events coming from SaaS providers (like monitoring tools, CRMs) and integrate them into internal workflows. For example, receive alerts from Datadog, PagerDuty, then trigger internal remediation.<\/li>\n<li>When a file is uploaded to an S3 bucket, it can trigger ETL or Lambda function to process data.<\/li>\n<li>If a database record changes (e.g. DynamoDB stream), trigger downstream services.<\/li>\n<\/ol>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>The event driven workflow is quite vast, so depending on your use cases, you can configure them with other services.<\/p>\n<p>Both the services are serverless so you will pay for what you use. The pricing of the AWS <a href=\"https:\/\/aws.amazon.com\/eventbridge\/pricing\/?ref=devopscube.com\" rel=\"noreferrer\">EventBridge<\/a> and <a href=\"https:\/\/aws.amazon.com\/lambda\/pricing\/?ref=devopscube.com\" rel=\"noreferrer\">Lambda<\/a> depends on the events, requests, and the duration of the execution.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/trigger-aws-lambda-function-using-event-bridge-rule\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Trigger an AWS Lambda Function using an Event Bridge Rule? \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/trigger-aws-lambda-function-using-event-bridge-rule\/<\/p>\n","protected":false},"author":1,"featured_media":489,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=488"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/488\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/489"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}