Understanding Event-Driven Architecture – CloudWatch and CloudWatch Metrics – SCS-C02 Study Guide

Understanding Event-Driven Architecture

EDA is a software design pattern in which the flow of the system is determined by events rather than a central control flow. In EDA, the system responds to events that occur asynchronously, such as messages received from AWS services, custom events, or even third-party Software as a Service (SaaS) applications.

An event-driven system consists of three main components:

  • Event producers: These are the components or processes that generate events.
  • Event consumers: These are the components that react to the events and can include things such as handlers and workflows. They are shown in Figure 8.19 as Targets.
  • Event bus: This communication channel allows event producers and consumers to exchange event data. It provides a loosely coupled mechanism for event-driven systems to interact with each other.

EDA has the following advantages:

  • Scalability: Event-driven systems can easily scale horizontally by adding more producers or consumers as needed.
  • Flexibility: Because events are loosely coupled, modifying or replacing individual components is easy without affecting the entire system.
  • Responsiveness: Event-driven systems can respond quickly to events as they occur rather than waiting for a central control flow to process requests.
  • Resilience: Event-driven systems can recover from failures quickly and easily by restarting failed components and resuming event processing.

With a basic understanding of how the EventBridge service works, you are now ready to examine how to use targets by combining the Lambda and SNS services and Amazon EventBridge.

Using EventBridge with AWS Lambda and SNS

In Chapter 5, Managing Your Environment with AWS Config, you looked at how AWS Config could be used to record and track changes to your infrastructure as soon as they happen and how these events can be written to logs and processed into other services, such as Amazon CloudWatch. Using this data, you can configure controls to look for specific events for further investigation. These could be events that might signify a security breach or a threat.

This is a simple method of implementing an automated level of remediation by monitoring and identifying events from different services to look for potential security breaches and implementing an automated response using AWS Lambda to rectify the problem. In addition to CloudWatch log groups, you can use Amazon EventBridge to trigger a service such as Lambda to provide the remediation or fix for the issue discovered in the CloudWatch log group.

To briefly recap, AWS Lambda is a serverless compute service that automatically provisions compute power, allowing you to run code for your applications either on-demand or in response to events without having to provision any compute resources yourself. Using this serverless technology removes a level of administrative responsibility of maintaining a compute instance; instead, that is all managed by AWS. This allows you to focus purely on the application and logic code.

Removing the need to provision and run an EC2 instance can provide significant cost savings as, when using AWS Lambda, it only charges you for the compute power per 100 ms of use when your code is running, in addition to the number of times your code is run.

EventBridge events can be used to react to specific events within your infrastructure, which can trigger an automated response.