DEV Community

LaTerral Williams
LaTerral Williams

Posted on

πŸ›‘οΈ AWS Config Drift Detection Lab - Beginner-Friendly Guide

⭐ Why I Built This Project

(Project 4 of 6 β€” Drift Detection with AWS Config)

Instead of studying cloud security concepts in isolation, I’m using real job descriptions as a roadmap and building hands-on projects that map directly to cloud security, cloud operations, and security engineering.

This 6-part series focuses on practical, resume-ready cloud security skills, including:

  • Identity hardening and MFA enforcement
  • IAM governance and access reviews
  • Continuous monitoring of cloud resources
  • Misconfiguration detection & drift analysis
  • Log analysis, audit readiness, and evidence gathering
  • Guard rails at scale using AWS Organizations + Service Control Policies (SCPs)
  • Threat detection, anomaly monitoring, and incident triage

Each project is designed to reflect real-world responsibilities, not just theoretical learning.


πŸ“Œ Project Sequence

πŸ‘‰ Part 1: AWS IAM Hardening β€” strengthening identity boundaries and improving authentication hygiene

πŸ‘‰ Part 2: Cloud Security Posture Management (CSPM) using Security Hub + AWS Config

πŸ‘‰ Part 3: CASB-Like Monitoring with GuardDuty + CloudTrail, focusing on anomalies, delegated admin, and safe threat simulation

πŸ‘‰ Part 4: (this project) β€” Drift Detection with AWS Config, using managed Config rules, scoped evaluations, EventBridge routing, SNS notifications, and optional auto-remediation to detect when cloud resources deviate from approved security baselines


πŸ” Why This Progression Matters

Modern cloud security teams approach protection in layers:

Identity first β†’ Posture second β†’ Threat Detection β†’ Drift Governance

After establishing IAM hygiene (Project 1), posture baselines (Project 2), and threat intel/anomaly detection (Project 3), the next natural step is detecting when cloud resources drift away from their intended configuration.

Drift detection is critical because:

  • Many breaches originate from accidental misconfigurations
  • Public S3 buckets remain a top cloud security incident
  • Compliance frameworks require continuous configuration monitoring
  • Security teams rely on automated alerts not manual checks

This project simulates a realistic workflow used by cloud security analysts, compliance engineers, and platform security teams by combining:

  • AWS Config managed rules
  • Scoped evaluations (tags, resource types)
  • EventBridge event pattern filtering
  • SNS notification routing
  • Optional SSM auto-remediation actions
  • Cost-safe cleanup practices

You’ll intentionally make an S3 bucket public, watch AWS detect the drift, trigger an automated alert, and optionally repair the issue automatically... a true end-to-end cloud security workflow.


A hands‑on walkthrough using AWS Config, EventBridge, and SNS to detect when an S3 bucket becomes public (a classic example of security drift).

This is a fun, friendly, technical guide designed for absolute beginners including troubleshooting from a real-world lab run.


πŸ“˜ Table of Contents

  1. Introduction
  2. What Is Drift Detection?
  3. Architecture Overview
  4. Prerequisites & Cost Notes
  5. Step 1 β€” Create a Config Logs Bucket
  6. Step 2 β€” Enable AWS Config (S3-Only Setup)
  7. Step 3 β€” Create the Drift-Test S3 Bucket
  8. Step 4 β€” Add the AWS Config Rule
  9. Step 5 β€” Create SNS Topic for Alerts
  10. Step 6 β€” Create EventBridge Rule
  11. Step 7 β€” Introduce Drift
  12. Step 8 β€” Verify Detection & Alerts
  13. Troubleshooting & Gotchas
  14. Cleanup
  15. Final Thoughts

πŸ”° Introduction

Cloud environments change fast. Sometimes too fast β€” and not always intentionally.

This lab shows you how to detect unwanted changes (drift) using:

  • AWS Config β†’ Detects drift
  • Amazon EventBridge β†’ Routes drift events
  • Amazon SNS β†’ Sends email alerts

You’ll break an S3 bucket on purpose and watch AWS alert you.

You'll also see real-world troubleshooting issues I hit along the way and how to fix them.


πŸŒͺ️ What Is Drift Detection?

Security drift happens when a resource moves away from your intended configuration.

Example:

  • You want your S3 bucket private
  • Someone makes it public
  • Drift detected! πŸ””

This lab focuses on detecting when an S3 bucket becomes publicly accessible.


πŸ—οΈ Architecture Overview

High-level flow:

  1. You create a private S3 bucket
  2. AWS Config evaluates it using a managed rule
  3. You introduce drift (make it public)
  4. Config marks it NON_COMPLIANT
  5. EventBridge catches the change
  6. SNS sends you an email alert

πŸ› οΈ Prerequisites & Cost Notes

You Need:

  • An AWS account
  • Basic IAM permissions:
    • AWSConfigFullAccess
    • S3FullAccess
    • EventBridgeFullAccess
    • SNSFullAccess

Cost Notes:

AWS Config is not fully free-tier.

To keep this project low cost:

  • Use one region
  • Track only S3 resources
  • Use a single rule
  • Delete everything at the end (cleanup section included)

πŸͺ£ Step 1 β€” Create a Config Logs Bucket

  1. Go to S3 β†’ Create Bucket
  2. Name it something like:

config-logs-lab-<yourinitials>-123

  1. Enable Block Public Access
  2. Leave default encryption on
  3. Click Create Bucket

πŸ“ Step 2 β€” Enable AWS Config (S3-Only)

  1. Open AWS Config β†’ Set Up
  2. Choose Record specific resource types
  3. Select:
  • AWS::S3::Bucket
  • (Optional but recommended) AWS::S3::AccountPublicAccessBlock
    1. Set the delivery S3 bucket to the one you created
    2. Skip SNS notifications (we’ll create our own later)

πŸͺ£ Step 3 β€” Create the Drift-Test S3 Bucket

Name example:

drift-demo-bucket-<yourinitials>-123

  1. Create the bucket
  2. Keep Block Public Access = ON
  3. Add tag:
Key: Project
Value: ConfigDriftLab
Enter fullscreen mode Exit fullscreen mode

This tag lets us scope the Config rule later.


🧩 Step 4 β€” Add the AWS Config Rule

Search for the managed rule:

βœ… s3-bucket-level-public-access-prohibited

This is the new bucket-level drift rule that detects whether bucket policies or ACLs make the bucket public.

Set Scope to:

  • Resources with specific tags
  • Key: Project
  • Value: ConfigDriftLab


πŸ“£ Step 5 β€” Create SNS Topic for Alerts

  1. Go to SNS β†’ Topics β†’ Create Topic
  2. Name: drift-alerts-test-topic
  3. Create
  4. Add a subscription:
    • Protocol: Email
    • Endpoint: your email address
  5. Confirm the email in your inbox


πŸ”” Step 6 β€” Create EventBridge Rule

This rule listens for AWS Config compliance changes.

Use this event pattern:

{
  "source": ["aws.config"],
  "detail-type": ["Config Rules Compliance Change"],
  "detail": {
    "configRuleName": ["s3-bucket-level-public-access-prohibited"],
    "newEvaluationResult": {
      "complianceType": ["NON_COMPLIANT"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Set the Target = SNS topic you just created.

If needed, re-add the target so EventBridge automatically updates the SNS policy.


πŸ’₯ Step 7 β€” Introduce Drift (Make the Bucket Public)

To simulate drift:

  1. Disable Block Public Access
  2. Add a public bucket policy:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicRead",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::drift-demo-bucket-<yourinitials>-123/*"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

AWS Config will soon detect this change.


πŸ“¨ Step 8 β€” Verify Drift Detection & Alerts

You should see:

AWS Config β†’ Rule Status:

NON_COMPLIANT πŸ”΄

EventBridge β†’ Monitoring:

Invocations > 0

SNS Email β†’

Check inbox and spam folder (real story from this lab πŸ˜…)


🧰 Troubleshooting & Gotchas (Real Lab Issues)

This section includes both a narrative + clean reference list, based on actual problems encountered while building this project.


🧡 Narrative: What Actually Broke & How I Fixed It

1. SNS Never Delivered the Alert

Turns out the SNS topic had the default policy, which does NOT allow EventBridge to publish messages.

Fix:

I added this to the SNS Access Policy:

{
  "Sid": "Allow_EventBridge_Publish",
  "Effect": "Allow",
  "Principal": {
    "Service": "events.amazonaws.com"
  },
  "Action": "SNS:Publish",
  "Resource": "arn:aws:sns:us-east-1:<account-id>:drift-alerts-test-topic",
  "Condition": {
    "ArnEquals": {
      "aws:SourceArn": "arn:aws:events:us-east-1:<account-id>:rule/aws-config-drift-to-sns"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

2. The First Alert Went to Spam

SNS emails come from:

no-reply@sns.amazonaws.com

I marked it as Not Spam so future alerts land correctly.

3. Config Rule Name Mismatch

AWS updated the naming of S3 Config rules.

The correct one is:

βœ” s3-bucket-level-public-access-prohibited


πŸ“‹ Clean Troubleshooting Checklist

Problem Fix
No email alert Confirm SNS subscription is Confirmed
EventBridge not firing Check Monitoring tab for Matches
Invalid pattern Temporarily test with { "source": ["aws.config"] }
SNS access denied Add EventBridge β†’ SNS publish policy
Alert went to spam Mark β€œNot Spam”
No event emitted Ensure compliance changed from COMPLIANT β†’ NON_COMPLIANT

🧹 Cleanup (Avoid Costs!)

Delete in this order:

  1. Drift S3 bucket
  2. AWS Config rule
  3. Stop Configuration Recorder
  4. Delete delivery channel
  5. Delete Config logs bucket
  6. Delete EventBridge rule
  7. Delete SNS topic & subscription
  8. Delete IAM roles used for remediation (if any)

This ensures AWS Config stops billing you.


πŸŽ‰ Final Thoughts

You just built:

  • Drift detection
  • Automated alerting
  • AWS Config recording pipeline
  • Real debugging scenarios

This is a perfect beginner‑friendly cloud security project to show on a resume or portfolio.πŸš€


🀝 Connect

If you enjoyed this article or you’re also learning DevOps, Linux, Security, or Cloud automation, I’d love to connect, share ideas, and learn.

πŸ’¬ Feel free to reach out or follow my journey on πŸ‘‰ LinkedIn

Top comments (0)