BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeAWS Certified DevOps Engineer - Professional (DOP-C02)Lab: Auto-Remediating Non-Compliant S3 Buckets with AWS Config
Hands-On Lab890 words

Lab: Auto-Remediating Non-Compliant S3 Buckets with AWS Config

Implement configuration changes in response to events

Lab: Auto-Remediating Non-Compliant S3 Buckets with AWS Config

In this lab, you will implement an event-driven configuration change. You will use AWS Config to monitor S3 bucket settings and automatically trigger AWS Systems Manager (SSM) Automation to remediate a bucket that has public access enabled, ensuring your infrastructure remains in a desired, secure state.

[!WARNING] Remember to run the teardown commands at the end of this lab to avoid ongoing charges for AWS Config recorders.

Prerequisites

  • An AWS Account with Administrator access.
  • AWS CLI installed and configured with credentials.
  • Basic knowledge of IAM Roles and S3.
  • AWS Config should be initialized in your region (this lab provides commands to do so).

Learning Objectives

  • Configure an AWS Config Managed Rule to detect non-compliant resources.
  • Implement an automated remediation action using AWS Systems Manager.
  • Use Amazon EventBridge logic to bridge configuration changes to corrective actions.
  • Verify system state restoration after a policy violation.

Architecture Overview

Loading Diagram...
Figure 1 — Mermaid diagram

Architecture Breakdown (Visual)

Compiling TikZ diagram…
⏳
Running TeX engine…
This may take a few seconds
Figure 2 — TikZ diagram

Step-By-Step Instructions

Step 1: Create a Non-Compliant S3 Bucket

We will create a bucket and explicitly allow public access to trigger our event-driven workflow.

bash
# Generate a unique name BUCKET_NAME=brainybee-lab-config-$(date +%s) # Create the bucket aws s3api create-bucket --bucket $BUCKET_NAME --region <YOUR_REGION> --create-bucket-configuration LocationConstraint=<YOUR_REGION> # Disable Public Access Block (to make it non-compliant) aws s3api put-public-access-block \ --bucket $BUCKET_NAME \ --public-access-block-configuration "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false"
▶Console Alternative
  1. Navigate to
S3
Create bucket

. 2. Name it

brainybee-lab-config-xxx

. 3. Uncheck

Block all public access

. 4. Click

Create bucket

.

Step 2: Deploy the AWS Config Rule

We will deploy a managed rule that checks if S3 buckets have public access blocked.

bash
# Deploy the managed rule aws configservice put-config-rule \ --config-rule '{"ConfigRuleName": "s3-bucket-public-access-prohibited", "Source": {"Owner": "AWS", "SourceIdentifier": "S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED"}}'
▶Console Alternative
  1. Go to
AWS Config
Rules
Add rule

. 2. Search for

s3-bucket-level-public-access-prohibited

. 3. Click

Next

and

Add rule

.

Step 3: Configure Automated Remediation

Link the Config rule to the SSM Automation document AWS-ConfigureS3PublicAccessBlock.

bash
# Associate remediation aws configservice put-remediation-configuration \ --config-rule-name s3-bucket-public-access-prohibited \ --target-id AWS-ConfigureS3PublicAccessBlock \ --target-type SSM_CONTROLS \ --parameters '{"BucketName": {"ResourceValue": {"Value": "RESOURCE_ID"}}, "BlockPublicAcls": {"StaticValue": {"Values": ["true"]}}, "IgnorePublicAcls": {"StaticValue": {"Values": ["true"]}}, "BlockPublicPolicy": {"StaticValue": {"Values": ["true"]}}, "RestrictPublicBuckets": {"StaticValue": {"Values": ["true"]}}}' \ --automatic-remediation

[!IMPORTANT] The RESOURCE_ID parameter is a dynamic placeholder that AWS Config replaces with the actual bucket name when the rule triggers.

Checkpoints

Checkpoint 1: Rule Compliance Status

Wait 2-3 minutes for the Config recorder to run, then check the compliance status.

bash
aws configservice get-compliance-details-by-config-rule --config-rule-name s3-bucket-public-access-prohibited

Expected Result: The ComplianceType should initially be NON_COMPLIANT and then transition to COMPLIANT after remediation.

Checkpoint 2: S3 Resource Verification

Verify the bucket settings have been automatically changed to "Block All Public Access".

bash
aws s3api get-public-access-block --bucket <YOUR_BUCKET_NAME>

Expected Result: All four boolean values (BlockPublicAcls, etc.) should now be true.

Troubleshooting

ProblemPossible CauseFix
Rule stays "Insufficient Data"Config Recorder is offRun aws configservice start-configuration-recorder --configuration-recorder-name default
Remediation FailsMissing IAM PermissionsEnsure the Config service role has ssm:StartAutomationExecution and s3:PutBucketPublicAccessBlock permissions
Bucket not detectedRegional MismatchEnsure the S3 bucket and the Config Rule are in the same AWS Region

Clean-Up / Teardown

To avoid charges, delete the resources created during this lab:

bash
# Delete the S3 Bucket aws s3 rb s3://$BUCKET_NAME --force # Delete the Config Rule (and its remediation configuration) aws configservice delete-config-rule --config-rule-name s3-bucket-public-access-prohibited # Optional: Stop Config Recorder (Only if you don't use Config for other things) # aws configservice stop-configuration-recorder --configuration-recorder-name default

Stretch Challenge

Scenario: Instead of a managed SSM document, create a Custom Lambda Function that sends an SNS notification to the Security Team whenever a bucket is auto-remediated.

  • Hint: Use Amazon EventBridge to capture the Config Rules Compliance Change event where newEvaluationResult is COMPLIANT and the oldEvaluationResult was NON_COMPLIANT.

Cost Estimate

ServiceEstimated Cost (Lab Duration)
AWS Config~$0.003 per configuration item recorded
S3Free Tier (negligible storage/requests)
SSM AutomationFree (for standard AWS owned documents)
Total<$0.10 USD

Concept Review

ServiceRole in this Lab
AWS ConfigActs as the continuous auditing engine; detects when configuration drifts from the policy.
SSM AutomationProvides the execution logic to modify infrastructure and enforce the "Desired State."
Event-DrivenThe workflow is reactive (Event -> Detect -> Act) rather than scheduled (Polling).
RemediationThe act of returning a resource to compliance without manual intervention.
All AWS Certified DevOps Engineer - Professional (DOP-C02) Study Resources

Related Notes

  • Incident and Event Response: Implementing Automated Configuration Changes860 words
  • Mastering AWS Alerting and Automated Remediation1,050 words
  • Study Guide: Analyzing Failed Deployments in AWS940 words
  • Incident Analysis: Troubleshooting Failed Processes in AWS1,050 words
  • Mastering AWS Monitoring & Security Analytics: Logs, Metrics, and Findings1,050 words
  • AWS Log Analysis: Athena, CloudWatch Insights, and OpenSearch920 words
  • Analyzing Real-Time Log Streams with Amazon Kinesis Data Streams985 words
  • CloudWatch Anomaly Detection Alarms: Professional Study Guide820 words
  • AWS Application Storage Patterns: EBS, EFS, and S31,054 words
  • Lab: Automating Security Controls and Data Protection with AWS Secrets Manager and Config942 words
  • Master Study Guide: Automating Security Controls & Data Protection (AWS DOP-C02)1,184 words
  • Mastering AWS CloudFormation StackSets: Multi-Account & Multi-Region Orchestration895 words

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

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

Start Studying

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

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

Start Studying — Free
AWS Certified DevOps Engineer - Professional (DOP-C02) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, left to right. S3 Bucket connects to AWS Config (Configuration Change). B connects to SSM Automation (Non-Compliant). C connects to S3 Bucket"] -->|Configuration Change| B{"AWS Config (Remediate). B connects to EventBridge (Event). D connects to CloudWatch Logs (Notify).