Introduction

Introduction

Protecting data from cyberattacks and ransomware is a critical responsibility. Taking the necessary steps to detect anomalous activity at every level within the organization can help keep your data as safe as possible. Data storage is an important component where you can and should deploy anomaly detection.

To protect data storage, we will build a simple serverless pipeline to detect anomalies occurring on Amazon Elastic Block Store (EBS) volumes. We will use AWS Backup along with several other AWS managed services to build this solution.

The solution starts with AWS Backup. When an Amazon EBS volume is backed up, a snapshot is created. By comparing the current snapshot to a previously created snapshot, we can easily determine the number of changed blocks between the two snapshots. This changed value is pushed to Amazon CloudWatch as a custom metric, where an Amazon CloudWatch alarm is configured to detect anomalies. By leveraging the powerful built-in machine learning capabilities of Amazon CloudWatch, anomalies are detected and surfaced when the value breaches the threshold band of the alarm. When this happens, any pre-configured alarm notifications will be triggered.

To build the anomaly detection pipeline, we will use the following services:

  • AWS Backup: We will use AWS Backup to manage backups of Amazon EBS volumes. A backup plan will be created to select EBS volumes based on the tag key you provide during setup. Once the backup process starts, a snapshot is created, and events from the AWS Backup process will be sent to Amazon EventBridge.
  • Amazon EventBridge: Amazon EventBridge is a serverless event bus that receives events sent from AWS Backup. For backup events that match a pre-configured rule, EventBridge will trigger an AWS Lambda function.
  • AWS Lambda: All AWS Backup events matching the rule on Amazon EventBridge are routed to AWS Lambda. From this event, the AWS Lambda function extracts the Amazon Resource Name (ARN) of the Amazon EBS volume and the current snapshot name. Using the ARN as a key, the details of the previous backup snapshot are retrieved from an Amazon DynamoDB table. If a previous snapshot item is found for the given ARN, the current and previous snapshots are compared for changes. The calculated change value is sent to Amazon CloudWatch as a custom metric. If no previous snapshot item is found in the Amazon DynamoDB table, a new item is created, and an Amazon CloudWatch alarm is configured for that ARN.
  • Amazon DynamoDB: For each backup event sent to the AWS Lambda function, an Amazon DynamoDB table is used to persist event details. The ARN from the event is used as the partition key, and the snapshot name is added as an attribute to the item.
  • Amazon CloudWatch: A custom metric is created in the AWS Lambda function and sent to Amazon CloudWatch. The metric value contains the number of changed blocks between the current snapshot and the previous snapshot. A CloudWatch alarm, which was configured and created earlier in the AWS Lambda function, will be triggered when the value breaches the anomaly detection threshold band.
  • Amazon Simple Notification Service (Amazon SNS): When a CloudWatch alarm is triggered, the Amazon SNS topic will send a notification to the email address configured during setup.

EBS