Hands-On Lab842 words

Lab: Implementing Automated Security Monitoring and Alerting with Amazon GuardDuty

Design and implement monitoring and alerting solutions for an AWS account or organization

Lab: Implementing Automated Security Monitoring and Alerting with Amazon GuardDuty

This hands-on lab guides you through the process of designing and implementing a centralized monitoring and alerting solution using Amazon GuardDuty, Amazon EventBridge, and Amazon Simple Notification Service (SNS). This architecture is a foundational component for the AWS Certified Security - Specialty (SCS-C03) curriculum.

[!WARNING] Remember to run the teardown commands at the end of this lab to avoid ongoing charges. GuardDuty offers a 30-day free trial, but SNS and EventBridge may incur costs depending on usage.

Prerequisites

To successfully complete this lab, you will need:

  • An AWS Account with AdministratorAccess or equivalent permissions.
  • AWS CLI installed and configured on your local machine.
  • A valid email address to receive security alerts.
  • Basic familiarity with the AWS Management Console and JSON syntax.

Learning Objectives

By the end of this lab, you will be able to:

  1. Enable Amazon GuardDuty to monitor for malicious activity and unauthorized behavior.
  2. Create an SNS Topic and subscription to facilitate automated notifications.
  3. Configure EventBridge Rules to filter GuardDuty findings and route them to targets.
  4. Test the alerting pipeline using sample findings to ensure the solution functions as designed.

Architecture Overview

The following diagram illustrates the flow of security events from detection to notification:

Loading Diagram...

Step-by-Step Instructions

Step 1: Enable Amazon GuardDuty

Amazon GuardDuty is a threat detection service that continuously monitors your AWS accounts and workloads for malicious activity.

bash
# Create a detector for the current region aws guardduty create-detector --enable
Console Alternative
  1. Navigate to the Amazon GuardDuty console.
  2. Click Get Started.
  3. Click Enable GuardDuty.

Step 2: Create an SNS Topic for Security Alerts

We need a communication channel to broadcast findings to the security team.

bash
# Create the SNS Topic aws sns create-topic --name "brainybee-security-alerts"

[!NOTE] Take note of the TopicArn returned in the output. You will need it for the next steps.

Step 3: Subscribe an Email to the SNS Topic

Replace <YOUR_EMAIL> with your actual email address and <TOPIC_ARN> with the ARN from Step 2.

bash
aws sns subscribe \ --topic-arn <TOPIC_ARN> \ --protocol email \ --notification-endpoint <YOUR_EMAIL>

[!IMPORTANT] Check your email inbox and click Confirm Subscription in the email sent by AWS. The status must be "Confirmed" for alerts to be delivered.

Console Alternative
  1. Go to Simple Notification Service > Topics.
  2. Select brainybee-security-alerts.
  3. Click Create subscription.
  4. Protocol: Email; Endpoint: your email address.
  5. Check your inbox and confirm the subscription.

Step 4: Create an EventBridge Rule for GuardDuty Findings

We will create a rule that triggers whenever GuardDuty generates a finding with a severity level of "High" (severity >= 7.0).

bash
# Create the rule aws events put-rule \ --name "GuardDutyHighSeverityRule" \ --event-pattern '{"source":["aws.guardduty"],"detail-type":["GuardDuty Finding"],"detail":{"severity":[7, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9]}}' \ --state ENABLED

Now, add the SNS topic as the target for this rule:

bash
aws events put-targets \ --rule "GuardDutyHighSeverityRule" \ --targets "Id"="1","Arn"="<TOPIC_ARN>"

Step 5: Test the Alerting Pipeline

Since we don't want to actually attack our account, we will generate a sample finding to trigger the rule.

bash
# Get your Detector ID DETECTOR_ID=$(aws guardduty list-detectors --query 'DetectorIds[0]' --output text) # Generate sample findings aws guardduty create-sample-findings \ --detector-id $DETECTOR_ID \ --finding-types "Backdoor:EC2/C&CActivity.B!DNS"

Checkpoints

CheckpointActionExpected Result
SNS SubscriptionCheck SNS consoleSubscription status should be Confirmed.
EventBridge RuleRun aws events list-rulesGuardDutyHighSeverityRule should be in the list.
Alert ReceiptCheck your emailYou should receive a JSON-formatted email from SNS within 5 minutes.

Troubleshooting

Error/IssueCommon CauseFix
No email receivedSubscription not confirmedCheck your spam folder and confirm the SNS subscription.
EventBridge target failsMissing SNS Resource PolicyEnsure SNS allows EventBridge to publish. Add a policy allowing events.amazonaws.com to sns:Publish.
GuardDuty sample failsIncorrect Detector IDRun aws guardduty list-detectors to verify you are using the correct ID for your region.

Clean-Up / Teardown

To avoid ongoing costs, delete the resources created during this lab.

bash
# 1. Delete the EventBridge Target and Rule aws events remove-targets --rule "GuardDutyHighSeverityRule" --ids "1" aws events delete-rule --name "GuardDutyHighSeverityRule" # 2. Delete the SNS Topic (This also deletes subscriptions) aws sns delete-topic --topic-arn <TOPIC_ARN> # 3. Disable GuardDuty aws guardduty delete-detector --detector-id $DETECTOR_ID

Concept Review

This lab implemented a reactive detection pattern. In a production environment, you might consider these alternatives:

FeatureGuardDuty + SNS (This Lab)Security Hub + Step Functions
Primary GoalSimple NotificationAutomated Remediation
ComplexityLowHigh
Use CaseInforming a human adminIsolating a compromised EC2 instance automatically

Ready to study AWS Certified Security - Specialty (SCS-C03)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free