Evaluating Compliance with AWS Config Rules
This lesson explains how AWS Config records the configuration of resources and evaluates it against rules, providing a continuous view of compliance and a history of every change.
Learning outcomes
After completing this lesson, you will be able to:
- Configure the configuration recorder.
- Choose managed and custom rules.
- Attach remediation actions to rules.
The configuration recorder
The configuration recorder captures configuration items whenever supported resources are created, changed or deleted, with relationships to other resources. It can record all resource types or selected ones, with continuous or daily recording frequency per type to control cost, and it needs a service-linked role. A delivery channel sends configuration history and snapshots to an S3 bucket and optionally notifications to SNS. Config is Regional, so it must be enabled in each Region in use; global resources such as IAM are recorded in one Region. The configuration timeline of a resource shows what changed, when, and the linked CloudTrail event showing who made the change.
Rules
A Config rule evaluates resources and reports them COMPLIANT or NON_COMPLIANT. AWS managed rules cover hundreds of common checks, such as restricted-ssh, encrypted-volumes, s3-bucket-public-read-prohibited, rds-multi-az-support, required-tags, cloudtrail-enabled and approved-amis-by-id. Custom rules are written as Lambda functions or in CloudFormation Guard policy language (custom policy rules). Rules are triggered by configuration changes to the resource types in scope, periodically (every 1, 3, 6, 12 or 24 hours), or both. Proactive evaluation mode checks resource configurations before deployment through CloudFormation hooks.
| Rule type | Written as | Example |
|---|---|---|
| AWS managed | Predefined by AWS | encrypted-volumes, restricted-ssh |
| Custom Lambda | Lambda function | Check a value in a third-party CMDB |
| Custom policy (Guard) | Guard DSL in the rule | Require specific tags and settings without code |
Change-triggered or periodic?
Remediation
A rule can have a remediation action: a Systems Manager Automation runbook (for example AWS-DisableIncomingSSHOnPort22 or AWSConfigRemediation-EnableS3BucketEncryption) with parameters that can take the non-compliant resource ID. Manual remediation is started by an operator; automatic remediation runs whenever a resource becomes non-compliant, with a retry limit and an assume role for permissions. Compliance changes are also published to EventBridge, which can trigger notifications or other automation.
aws configservice put-remediation-configurations --remediation-configurations '[{
"ConfigRuleName": "s3-bucket-server-side-encryption-enabled",
"TargetType": "SSM_DOCUMENT",
"TargetId": "AWSConfigRemediation-EnableS3BucketEncryption",
"Parameters": {
"AutomationAssumeRole": {"StaticValue": {"Values": ["arn:aws:iam::111122223333:role/ConfigRemediation"]}},
"BucketName": {"ResourceValue": {"Value": "RESOURCE_ID"}},
"SSEAlgorithm": {"StaticValue": {"Values": ["AES256"]}}
},
"Automatic": true, "MaximumAutomaticAttempts": 3, "RetryAttemptSeconds": 60
}]'The following diagram shows a rule detecting and fixing an open SSH rule.

Automatic remediation
Who opened the database to the internet?
The rds-instance-public-access-check rule reports a database as non-compliant. The resource's configuration timeline in Config shows that PubliclyAccessible changed from false to true yesterday at 16:20, and the linked CloudTrail event shows the ModifyDBInstance call and the role that made it. The operator reverts the setting, and the team adds an automatic remediation runbook and an SCP condition that denies rds:ModifyDBInstance with PubliclyAccessible set to true where possible.
Is AWS Config recording global, or per Region?
Show answer
Per Region, so it must be enabled in every Region used.
Exam Tips
Remember for the exam
- Config records configuration items and history per Region; enable it in every Region used.
- Rules evaluate on configuration change, periodically or both.
- Custom rules use Lambda or Guard; remediation uses Systems Manager Automation runbooks.
- The configuration timeline links changes to CloudTrail events.
- Config detects; SCPs and other preventive controls block.