‫So let's practice using Amazon EventBridge.
‫And for this we're going to go into the EventBridge console,
‫and then you have lots of options.
‫But for now, we're just going to create an EventBridge rule.
‫So let's create this rule, and the rule name is
‫going to be called InvokeLambdaEveryHour.
‫Now, if you click on schedule
‫you will see that there is a new capability
‫of EventBridge called EventBridge Scheduler.
‫And this is what we're going to use to
‫create this Lambda function scheduler.
‫So we're going to go into another console
‫and this is a new thing.
‫So it's called InvokeLambdaEveryHour.
‫And then it's a one time schedule
‫it's a recurring schedule, excuse me,
‫and then it's going to be a rate based
‫and we can say that we want every one hour to
‫have our Lambda function being invoked.
‫Okay?
‫Then we can specify more options about
‫the timing that we want to.
‫Flexible time we say of,
‫so that's we, happen to execute it exactly
‫every one hour.
‫Target API could be different targets.
‫In this case we're going to use AWS Lambda,
‫and then we need to select Lambda function.
‫So I'll just choose my demo Lambda, that's it
‫and then click on next.
‫And then whether or not we want to enable the schedule
‫and retry in case of errors,
‫we'll just leave everything as the default.
‫Then a role is created for me automatically.
‫I click on next, and then I create this schedule.
‫So by creating this schedule, we're having actually
‫something called EventBridge scheduler to run a schedule
‫and invoke our Lamda function.
‫This used to be something that was part
‫of EventBridge rules, but now has been separated.
‫Even though if you wanted to,
‫you could create a rule,
‫choose a schedule, and then instead
‫of clicking here continue in EventBridge schedule
‫you could just click on continue to create rule,
‫And there you go.
‫But it's not the recommended way.
‫So I'll just show you the better way,
‫with EventBridge scheduler.
‫So here with EventBridge scheduler
‫my schedule is now created,
‫and this is going to invoke my Lamda function
‫every one hour.
‫So it's quite nice.
‫But what if you wanted it to react
‫to events happening within your accounts in EventBridge?
‫So again, back into rules, we're going to create a rule.
‫So let's call this rule, send notification for login,
‫and we'll make sure this rule is triggered whenever
‫someone does a login into AWS.
‫So we'll use a rule with an event pattern and click on next
‫and then we'll use AWS events in it.
‫And then amongst the events of AWS,
‫we need to filter them.
‫So let's have a look at the event source.
‫So we scroll down, sorry,
‫and then we'll need to find a service.
‫And then we'll just type in console
‫to find the AWS Console Sign-in.
‫And then the event type will be Sign-in events.
‫So any user that signs in
‫through the console will trigger this events
‫pattern, which is amazing.
‫And then for the targets,
‫we can, for example send this into an SNS topic.
‫For example, my demo-ccp topic
‫And this will ensure that events are sent,
‫as SNS notifications whenever someone logs in.
‫So next, next, and then create rule and we're good to go.
‫So now anyone, someone logs into your account
‫you'll receive an SNS notification and email.
‫One last I can do,
‫for example is EC2InstanceTerminateNotifications.
‫So say you wanted to be notified anytime,
‫and this two instance was terminated for whatever reason.
‫So again, we'll use a rule
‫with an event pattern,
‫and then we'll use every services
‫and then we'll use the EC2 service,
‫And then we'll have a look
‫at the EC2 instance State-change notification.
‫And then what state do we want to change to?
‫So here we're can apply a filter and say,
‫Hey, I want to apply to specific states,
‫the state being terminated.
‫So whenever an instance goes to a terminated states
‫then this rule will apply
‫and here will apply to any instance.
‫So you can see EventBridge is very powerful,
‫and the event patterns can be quite complicated.
‫So next, what do we want to invoke?
‫For example, we can invoke, again, SNS topic
‫and send a message into the demo CCP topic.
‫So we have one more rule, and now you start to get an idea
‫around the power of EventBridge.
‫So we created three rules.
‫Now before we heads up MDs, hands on
‫you need to disable them, for example
‫or you need to just delete them, whatever you prefer.
‫And lastly, as you can see
‫there can be different event bus,
‫as I told you, I'm not going to go
‫into it because it's two events for this CCP level.
‫But you can send your own events into EventBridge
‫or you can have partners
‫of AWS send events into EventBridge as well
‫for you to react to them in real time.
‫So that's it for this lecture,
‫I hope you liked it and I will see you in the next lecture.