In this video.
We are going to continue to create a role, but this time we will create event matching pattern for
rule in Amazon event bridge using the development console.
So that means we are going to go to step two.
So please select the rule type as a rule with an event pattern and click the next button.
So see that this is the event pattern page that has some parts, which is the event source sample events.
If you scroll down, you can see the actual event pattern that we will follow and fill this event source
in here.
Okay.
First of all, we will choose and select the event source of the Amazon event bridge.
So the default complication is adverse events or event partner events that we will also select this
option because this will trigger event from the resources.
So if you scroll down, you can see two parts.
The first part is sample event and the second part is event pattern.
So the first part, the sample event part is optional, it is not required, but I will explain how
we can use it.
But if you come to event pattern, we will define event pattern in here.
If you look at the or event patterns, basically we can use a predefined pattern provided by a sources
or we can create a custom pattern.
If you click this button, we can see that we can create a custom patterns.
But I would like to see predefined patterns provide from the base.
If you click the event pattern form, you can see that there is an event source and a list services
we have select event source is a services and you can see the list source name.
For example, I'm searching for the S-3.
You can say that Amazon S3, which will be the our event source.
So after selecting the services that comes from event type, that means there is several events can
be triggered from the Amazon S3 If you open this box, you can see that there is different notification
or and so on.
I'm choosing the all events.
If you select to all events the event pattern generated from the alias that you can see that there is
only source attribute, which is the alias that is S3.
So that means every event happens from the A S3 will trigger our event rule into the Amazon event bridge.
So if you scroll up this time, I would like to show you how we can see the sample events will trigger
event which we can see the sample event generator box in here.
If you come here, select the services and you can see the all the sample events in the dropdown.
There is lots of event sources, sample events.
I'm going to search for the S3 and I would like to object created event in the S3.
If you select this section, you can see the generated predefined sample event.
You can see the details of this event.
If you check that event selected from the Amazon event, you can see the event, JSON version, ID ID
detail, type, source detail and so on.
So basically if we explain this sample event, there is a detail type is very important, which is the
object created and the source is very important, which is the S3.
So these events trigger outcomes when it comes to Amazon S3 Object Create Action happened.
So if you scroll down, you can see the details under the tail section, which could name and which
object name created on the Amazon S3.
Okay, very good.
Now I'm going to compare it with our event pattern.
So think about that.
Amazon S3 triggered this event and it comes to our event rule and our event pattern is works and it
is basically looking to source option.
So that means this event will trigger our rule because it makes our event pattern.
So basically event pattern is only looking for the source attribute into incoming event JSON.
If the source attribute exists, then compared with the Amazon S3, you can call you can see the source
attribute and go back to incoming sample event.
The source attributes are match.
So if you scroll down and click the test button, you can see that sample event matched the event pattern.
So we are simulating the incoming event from the sample event and after that we are creating our event
pattern and we can test in this window.
This is very powerful feature when we designing our role in the Amazon event page.
For example, if I change this sample event to the case and if you come here and click the test button,
you can see that sample event did not match because we are looking source as an Amazon S3, but the
source comes with the case.
So let me come back to S3 created and scroll down so you understand the idea how we can create event
pattern in the Amazon event page so we can add one more criteria or event pattern.
You can copy from the detail type in here.
And come here and click the edit pattern.
So if you add a new item, you should specify the brackets because this should be an array.
And as you can see that I have added the detail type as object created and this event pattern should
be JSON format.
And of course, as you can see, that is the invalid syntax.
We should remove this comma and now JSON is valid.
So if you click the test button now you can see that sample event makes the event pattern because it
is coming from the object created from the S3.
If you change the object created event from the S3, let me search for example, object, delete it
if you come here, see that the tail type is changed if you scroll down.
Now, if I test pattern, you can see that this event is not matched because this time detail type is
not object created.
It is an object related.
You understand the idea how we can create event pattern into our application.
Now I'm going to choose a little bit basic event button, which is the Amazon S3 all events and I'm
going to click the next button and see what's happened.
Make sure that you have selected a service S3 and all events and click the next button.
Okay, now it is time to select targets.
So in the Select Target, we are select target to invoke one an event match to our event pattern or
one schedule is triggered.
In the next video we are going to select the target.