0Pricing
AWS Solutions Architect · Lesson

AWS Config Rules and Remediation

Deploy managed and custom Config rules to detect non-compliant resources and use SSM Automation documents for automatic remediation.

AWS Config Rules and Remediation is a free AWS Solutions Architect lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is AWS Config?

AWS Config is a continuous configuration audit service that records the configuration state of your AWS resources over time and evaluates those configurations against desired rules. Unlike CloudTrail (which records who did what), AWS Config answers what does this resource look like right now? and what did it look like at any point in the past?. It also answers: does this configuration comply with my policy? — making it the go-to service for governance and compliance.

Configuration Items and Configuration History

When AWS Config records a resource, it creates a configuration item (CI) — a snapshot of the resource's attributes, relationships, and metadata at a point in time. Every time a resource changes, a new CI is recorded. AWS Config maintains a full configuration history for each resource, allowing you to see how a security group evolved over months and exactly when a rule was added or removed. CIs are delivered to an S3 bucket and optionally to CloudWatch Events.

# Get the full configuration history for an EC2 security group
aws configservice get-resource-config-history \
  --resource-type AWS::EC2::SecurityGroup \
  --resource-id sg-0abc1234def567890 \
  --limit 10 \
  --query 'configurationItems[].{Time:configurationItemCaptureTime,Status:configurationItemStatus}'

Enabling AWS Config

To start using AWS Config, you create a configuration recorder (specifying which resource types to record) and a delivery channel (specifying an S3 bucket and optional SNS topic for change notifications). You can record all supported resource types or a specific subset. A configuration aggregator lets you consolidate Config data from multiple accounts and Regions into a single view for organisation-wide compliance reporting.

# Enable AWS Config recording for all resource types
aws configservice put-configuration-recorder \
  --configuration-recorder \
    name=default,roleARN=arn:aws:iam::111122223333:role/AWSConfigRole \
  --recording-group allSupported=true,includeGlobalResourceTypes=true

# Set up delivery channel
aws configservice put-delivery-channel \
  --delivery-channel \
    name=default,s3BucketName=my-config-bucket-111122223333,snsTopicARN=arn:aws:sns:us-east-1:111122223333:ConfigChanges

aws configservice start-configuration-recorder --configuration-recorder-name default

AWS Config Rules: Managed Rules

Config rules define the desired configuration state for your resources. AWS Managed Config rules are pre-built rules provided by AWS covering common compliance checks — for example, s3-bucket-public-read-prohibited checks that S3 buckets are not publicly readable, ec2-instance-no-public-ip checks that EC2 instances don't have public IPs, and iam-password-policy verifies your account password policy meets complexity requirements. Over 300 managed rules are available.

# Add the managed rule to check S3 buckets are not publicly readable
aws configservice put-config-rule \
  --config-rule '{
    "ConfigRuleName": "s3-bucket-public-read-prohibited",
    "Source": {
      "Owner": "AWS",
      "SourceIdentifier": "S3_BUCKET_PUBLIC_READ_PROHIBITED"
    },
    "Scope": {
      "ComplianceResourceTypes": ["AWS::S3::Bucket"]
    }
  }'

# View compliance status of all rules
aws configservice describe-compliance-by-config-rule \
  --query 'ComplianceByConfigRules[].{Rule:ConfigRuleName,Compliance:Compliance.ComplianceType}'

Custom Config Rules with Lambda

When no AWS Managed rule covers your requirement, you can write a custom Config rule using an AWS Lambda function. Lambda receives configuration items as event payloads and must return a COMPLIANT or NON_COMPLIANT verdict. Custom rules can enforce organisation-specific naming conventions, required tags, approved AMI IDs, or any logic your compliance team requires. Rules can evaluate on change (when the resource changes), periodically (every 1/3/6/12/24 hours), or both.

# Register a custom Lambda-backed Config rule
aws configservice put-config-rule \
  --config-rule '{
    "ConfigRuleName": "required-tags-enforcer",
    "Source": {
      "Owner": "CUSTOM_LAMBDA",
      "SourceIdentifier": "arn:aws:lambda:us-east-1:111122223333:function:RequiredTagsChecker",
      "SourceDetails": [{
        "EventSource": "aws.config",
        "MessageType": "ConfigurationItemChangeNotification"
      }]
    },
    "Scope": {
      "ComplianceResourceTypes": ["AWS::EC2::Instance","AWS::S3::Bucket"]
    }
  }'

Proactive Rules with CloudFormation Guard

Config also supports proactive rules using AWS CloudFormation Guard — a policy-as-code language. Proactive rules evaluate resources before they are created via CloudFormation, AWS CDK, or Terraform Cloud, catching non-compliant configurations at deploy time rather than after they exist in production. This shifts compliance left in your infrastructure pipeline. Proactive evaluation is a newer feature that the SAA-C03 exam may reference in shift-left governance scenarios.

Automated Remediation with SSM

Config rules can be paired with automatic remediation actions so that non-compliant resources are fixed without human intervention. Remediation actions are AWS Systems Manager (SSM) Automation documents. For example, if an S3 bucket becomes non-compliant because someone enabled public access, Config can automatically run the AWS-DisableS3BucketPublicReadWrite SSM document to re-enable the bucket's public access block. Remediation can be automatic (immediate) or manual (triggered on demand).

# Add automatic remediation to a Config rule
aws configservice put-remediation-configurations \
  --remediation-configurations '[
    {
      "ConfigRuleName": "s3-bucket-public-read-prohibited",
      "TargetType": "SSM_DOCUMENT",
      "TargetId": "AWS-DisableS3BucketPublicReadWrite",
      "Parameters": {
        "S3BucketName": {"ResourceValue": {"Value": "RESOURCE_ID"}},
        "AutomationAssumeRole": {"StaticValue": {"Values": ["arn:aws:iam::111122223333:role/ConfigRemediationRole"]}}
      },
      "Automatic": true,
      "MaximumAutomaticAttempts": 3,
      "RetryAttemptSeconds": 60
    }
  ]'

Config Timeline and Resource Relationships

The AWS Config Resource Timeline in the console shows every configuration change for a resource as a timeline — you can scroll back to any point and see exactly what the resource looked like, including its relationships to other resources (for example, which security groups were attached, which IAM role was associated). Clicking on a relationship navigates to that related resource's timeline. This makes Config invaluable for root-cause analysis: you can pinpoint exactly which change broke production.

# Get current compliance status for all EC2 instances
aws configservice get-compliance-details-by-resource \
  --resource-type AWS::EC2::Instance \
  --resource-id i-0123456789abcdef0 \
  --query 'EvaluationResults[].{Rule:EvaluationResultIdentifier.EvaluationResultQualifier.ConfigRuleName,Compliance:ComplianceType}'

Aggregating Config Across Accounts

A configuration aggregator collects Config data from multiple AWS accounts and Regions into a single account for centralised compliance reporting. In an AWS Organisation, you can create an aggregator in the management account that automatically includes all member accounts without requiring individual authorisation. Aggregators support querying with Advanced Queries — a SQL-like interface to find all non-compliant resources across the organisation in seconds.

# Query all non-compliant resources across an organisation using Advanced Query
aws configservice select-aggregate-resource-config \
  --configuration-aggregator-name OrgAggregator \
  --expression "SELECT resourceId, resourceType, accountId, awsRegion
    WHERE complianceType = 'NON_COMPLIANT'
    AND resourceType = 'AWS::S3::Bucket'"
  --query 'Results'

Remediating at Scale

When you have thousands of non-compliant resources, Config's remediation exceptions let you exempt specific resources for a defined period with a documented reason — avoiding false-positive remediation of legitimate edge cases. For large-scale clean-up you can trigger manual remediation in bulk from the console or use Systems Manager State Manager associations to apply desired configurations to fleets of EC2 instances on a schedule, combining Config's detection with SSM's enforcement.

# Add a remediation exception for a specific resource
aws configservice put-remediation-exceptions \
  --config-rule-name s3-bucket-public-read-prohibited \
  --resource-keys ResourceType=AWS::S3::Bucket,ResourceId=my-public-website-bucket \
  --message 'Static website hosting requires public access' \
  --expiration-time 2025-01-01T00:00:00Z

AWS Config vs CloudTrail Comparison

A common SAA-C03 question is distinguishing Config from CloudTrail. CloudTrail answers: who did what, when, from where (API call audit log). AWS Config answers: what does the resource look like now, and what has it looked like over time (configuration state history and compliance). They are complementary — CloudTrail tells you that someone called ModifySecurityGroup at 3pm, while Config shows you the before-and-after state of the security group. Use both together for complete security governance.

Quick Check

Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.

Lesson Recap

In this lesson you learned: AWS Config records configuration state over time and evaluates resources against compliance rules, managed and custom rules check hundreds of resource attributes with automatic or on-demand evaluation, and SSM Automation remediation can automatically fix non-compliant resources without human intervention. Next up we explore Conformance Packs and Organisation Trails for enterprise-scale governance.

Frequently asked questions

Is the “AWS Config Rules and Remediation” lesson free?

Yes — the full text of “AWS Config Rules and Remediation” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.

What will I learn in “AWS Config Rules and Remediation”?

Deploy managed and custom Config rules to detect non-compliant resources and use SSM Automation documents for automatic remediation. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS Solutions Architect?

No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “AWS Config Rules and Remediation” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS Solutions Architect lesson?

Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. CloudTrail Trails and Event History
  2. CloudTrail Insights and Log File Integrity
  3. AWS Config Rules and Remediation
  4. Conformance Packs and Organisation Trails
← Back to AWS Solutions Architect