AWS Config: Rules, Conformance Packs and Auto-Remediation
Overview
AWS Config continuously records the configuration of your AWS resources and evaluates them against rules. It answers "what did this resource look like last Tuesday?" and "which resources violate our policy right now?". Each change creates a configuration item, and rules label resources COMPLIANT or NON_COMPLIANT.
Config is a building inspector who photographs every room each time something changes and checks the photos against the safety code. A conformance pack is a whole checklist (for example PCI-DSS) delivered as one package, and auto-remediation is the repair crew that fixes violations automatically.
CloudTrail answers who made which API call; Config answers what is the resulting configuration and is it compliant. The exam relies on that distinction, as well as managed vs custom rules, organisation-wide deployment and remediation with Systems Manager Automation.
Key Concepts
- The configuration recorder records resource changes (all or selected types) and delivers snapshots and history to an S3 bucket; it is regional.
- Rule types: managed rules (AWS-written), custom Lambda rules, and custom policy rules written in CloudFormation Guard (no Lambda needed).
- Triggers: configuration changes (on resource change) and periodic (1, 3, 6, 12 or 24 hours).
- Remediation actions run SSM Automation documents (e.g. AWS-DisablePublicAccessForSecurityGroup, AWS-EnableS3BucketEncryption) manually or automatically with retries.
- Conformance packs bundle rules and remediation in a YAML template; organisation conformance packs deploy to all accounts from the management or delegated administrator account.
- A multi-account, multi-Region aggregator collects compliance and configuration data into one account; it is read-only (does not deploy rules).
- Proactive evaluation checks a resource definition (such as a CloudFormation template) before it is deployed; CloudFormation Hooks can block non-compliant resources.
- Advanced queries use SQL-like syntax over current configuration; Config + EventBridge reacts to compliance changes.
Detailed Notes
Config vs CloudTrail vs CloudWatch
| Service | Question it answers |
|---|---|
| CloudTrail | Who called which API, when, from where? |
| Config | What is the configuration now/at a time, is it compliant, what changed? |
| CloudWatch | Performance metrics, logs and alarms |
Enabling and a managed rule
aws configservice put-configuration-recorder --configuration-recorder name=default,roleARN=$ROLE_ARN \
--recording-group allSupported=true,includeGlobalResourceTypes=false
aws configservice put-delivery-channel --delivery-channel name=default,s3BucketName=config-archive-111122223333
aws configservice start-configuration-recorder --configuration-recorder-name default
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"] }
}'
Include global resources (IAM) in one Region only to avoid duplicates.
Auto-remediation
{
"ConfigRuleName": "restricted-ssh",
"TargetType": "SSM_DOCUMENT",
"TargetId": "AWS-DisablePublicAccessForSecurityGroup",
"Automatic": true,
"MaximumAutomaticAttempts": 3,
"RetryAttemptSeconds": 60,
"Parameters": {
"AutomationAssumeRole": { "StaticValue": { "Values": ["arn:aws:iam::111122223333:role/ConfigRemediationRole"] } },
"GroupId": { "ResourceValue": { "Value": "RESOURCE_ID" } }
}
}
The remediation role must have permission to change the resource and be assumable by SSM. Use manual remediation for high-risk fixes requiring approval, and add an aws:approve step in the runbook. Always notify owners; silent fixes confuse teams.
Custom rules
| Option | Use |
|---|---|
| Managed rule | 300+ prebuilt checks such as encrypted-volumes, root-account-mfa-enabled, rds-multi-az-support |
| Custom policy (Guard) | Declarative logic, no code |
| Custom Lambda | Complex logic or calls to other APIs; Lambda must call PutEvaluations |
# Guard rule: S3 buckets must have versioning and tag CostCenter
rule s3_versioned when resourceType == "AWS::S3::Bucket" {
configuration.versioningConfiguration.status == "Enabled"
tags exists
}
Conformance packs
Resources:
EncryptedVolumes:
Type: AWS::Config::ConfigRule
Properties:
ConfigRuleName: encrypted-volumes
Source: { Owner: AWS, SourceIdentifier: ENCRYPTED_VOLUMES }
RootMfa:
Type: AWS::Config::ConfigRule
Properties:
ConfigRuleName: root-mfa
Source: { Owner: AWS, SourceIdentifier: ROOT_ACCOUNT_MFA_ENABLED }
aws configservice put-organization-conformance-pack --organization-conformance-pack-name baseline \
--template-s3-uri s3://config-packs/baseline.yaml --delivery-s3-bucket config-packs-delivery \
--excluded-accounts 111111111111
AWS provides sample packs for CIS, PCI DSS, HIPAA, NIST, Operational Best Practices. Org packs and org rules need trusted access and a delegated administrator.
Aggregators and queries
aws configservice put-configuration-aggregator --configuration-aggregator-name org \
--organization-aggregation-source RoleArn=$ROLE,AllAwsRegions=true
aws configservice select-aggregate-resource-config --configuration-aggregator-name org \
--expression "SELECT accountId, resourceId WHERE resourceType='AWS::EC2::Instance' AND configuration.imageId='ami-0old'"
Detect-fix-notify pattern
- Config rule flags a violation (event on EventBridge: Config Rules Compliance Change).
- Automatic remediation (SSM Automation) fixes the resource.
- EventBridge also sends the event to SNS/ticketing; Security Hub receives the finding.
- Dashboards track compliance percentage over time.
Proactive and preventive
Combine layers: SCP (prevent), CloudFormation Hook/Guard in pipeline (proactive), Config rule (detect) and remediation (correct). Config is detective; it cannot prevent a violation, only report and fix afterwards.
Costs and tips
Pricing is per configuration item recorded and per rule evaluation. Record only needed types in non-production, use periodic recording for high-churn resources and exclude noisy types (for example transient network interfaces) where compliance is not needed. Audit Manager maps Config and CloudTrail evidence to frameworks for auditors.
Conformance packs and remediation in practice
| Item | Detail |
|---|---|
| Rule types | AWS managed, custom Lambda, custom Guard (policy-as-code) rules |
| Triggers | Configuration change, periodic (1-24 h) |
| Organization rules and packs | Deployed by the management or delegated administrator account to all or selected accounts |
| Remediation | SSM Automation document per rule, manual or automatic, with retry attempts and concurrency limits |
| Aggregator | Collects compliance and configuration across accounts and Regions into one view |
Resources:
S3Encrypted:
Type: AWS::Config::ConfigRule
Properties:
ConfigRuleName: s3-sse-enabled
Source: { Owner: AWS, SourceIdentifier: S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED }
Remediation:
Type: AWS::Config::RemediationConfiguration
Properties:
ConfigRuleName: !Ref S3Encrypted
TargetType: SSM_DOCUMENT
TargetId: AWS-EnableS3BucketEncryption
Automatic: true
MaximumAutomaticAttempts: 3
RetryAttemptSeconds: 60
Parameters:
BucketName: { ResourceValue: { Value: RESOURCE_ID } }
SSEAlgorithm: { StaticValue: { Values: [AES256] } }
AutomationAssumeRole: { StaticValue: { Values: [!Sub "arn:aws:iam::${AWS::AccountId}:role/ConfigRemediation"] } }
Use proactive rules (evaluate CloudFormation templates before deployment) with detective rules so drift is both blocked and detected. Exclude the remediation role from the SCPs that would otherwise deny it.
Real World Example
Scenario: a healthcare company must prove encryption everywhere. An organisation conformance pack deploys rules for encrypted EBS volumes, RDS storage encryption, S3 default encryption and restricted SSH. Config aggregates data into the audit account.
S3 encryption violations trigger automatic remediation (enable default encryption) while public-security-group findings create a manual-approval remediation. EventBridge forwards non-compliance events to Security Hub and to the owning team's channel. Auditors receive evidence through Audit Manager.
Architecture Diagram
Rules evaluate recorded changes; remediation and notifications close the loop.
- 1The recorder captures a configuration change on a resource.
- 2Managed, Guard or Lambda rules evaluate the new configuration.
- 3A NON_COMPLIANT result triggers an automatic or manual remediation.
- 4The Automation runbook fixes the resource and the rule re-evaluates.
- 5The aggregator and Security Hub present organisation-wide compliance.
Best Practices
- ✓Deploy organisation conformance packs from a delegated administrator and aggregate centrally.
- ✓Use auto-remediation for low-risk fixes and approval workflows for risky ones; always notify owners.
- ✓Layer preventive (SCP/Hooks), detective (Config) and corrective controls.
- ✓Use Guard custom policy rules before writing Lambda rules.
- ✓Control cost by recording only necessary resource types in non-prod.
Common Interview Questions
Exam Tips
DOP-C02 focus
- "Continuously assess and auto-fix compliance" = Config rule + SSM Automation remediation.
- "Compliance across all accounts" = organisation conformance packs + aggregator.
- Config detects; SCPs and Hooks prevent.
- A custom rule without writing a Lambda = Guard custom policy rule.
Finished this lesson?
0 of 44 lessons done · 0% of the course

