Tutorial Highlights & Transcript
00:00 - What is Amazon EventBridge
Amazon EventBridge is a fully managed, serverless, and scalable Event Bus Service that makes it easy to build event-driven architecture by using data from your own applications, your AWS services, and the sales application. Sales applications can be Shopify, DataDog, and other field services. It connects the application data and allows you to ingest, filter, transform, and deliver events without writing custom code. Also, it enables you to set applied routing rules in which you can define event patterns based on the actual content of the events and define targets where the event needs to be sent. Here, there is an example. In this pattern, we have put the source S3 and the detail type object created. And the bucket name mentioned here is a Rashmi test bucket demo. This role will be initiated when the event created will match this pattern. An object created means when an object is uploaded in the S3 bucket, then this event will be triggered.
01:42 -Key Features
03:27 - Core Components
04:46 - How Does Amazon EventBridge Work?
07:19 - Demo of Amazon EventBridge
This is the default event. Every AWS account has a default path that is called the default event bus. We just will use this. In the rule, we will create a rule for ourselves. Let it be Demo111 or you can say any name here. There are two options to create the rule. If you want to just schedule a run, like if you want to run a Lambda function every 30 minutes, you can use this. For cron functionality, you can select this option and just add up deals here. If you want to execute that Lambda function every 30 minutes or 10 minutes, anything you can take and you will proceed to the next. Lambda will be involved every 30 minutes and it will match and this rule will be inserted.
For this demo, we will be using the first option as we need to match the pattern for the S3 object creation event. We will go to the next option as S3 is the AWS service so we will select the first service and here we will select S3. If you want to use this rule for any event created, then we can use all events but we want to execute it only if the object is uploaded in the S3 buckets. We will select this option, Amazon S3 event notification, and here we will specify that event. An object created we have selected and we can select a specific bucket here. We already have a bucket. We have defined a specific bucket here. In target, you can take a CloudWatch log group here and if you select this log group and name here anything the log group will be created with this name only and a role has been created. Now this will be in a running state once we upload an object in this S3 bucket. The object has been uploaded now, we can check the log group here. A log group has been created and we can see the event that the object has been uploaded in that specific bucket. We are seeing this event here only because it matches the event pattern. We have created this rule with this pattern, it is matching with this pattern that’s why we are able to win this event. If we deleted this bucket or this object then there will be no object here.
11:22 - Involving the Lambda Function
One more thing that I want to show is here. We can also send notifications to SNS topics. For that, we don’t need to change this target, we will keep the Lambda function. What we need to do is first create an SNS topic. It will be a standard one and give it a similar name again. We can add a subscription. We will subscribe from our email. Now what we will do is we will add this as a destination in our Lambda. Here we need to add the destination but before that, we need to add permissions for the SNS in the rule that was already added as a default. This is the rule that was by default added to the Lambda function. We will go to a similar role rather than create the new one and we will attach the policy for SNS access. Here are the permissions. What we will do is attach a policy for SNS. Now it should be able to access the SNS topic. So let’s get back to the destinations. As we want to send the notification when the Lambda function is successful, we have to select this option. Here we have selected SNS topics. Now, what we need to do again is just go to the S3, and upload an object here. We have received the notification that this event has occurred. Using EventBridge, we can filter events of our choice, and this is its benefit over the SNS. There, we cannot define the content of the event that we certainly want, but here we can define the EventBridge in the rule, so whatever type of events we want to have, we can define them.
Rashmi Goswami
Senior Support Engineer
nClouds
Rashmi is a Senior Support Engineer at nClouds with an AWS Certified Solution Architect - Professional certification.