Lesson 3 of 4 Monitoring and Governance

Recording Configuration and Enforcing Compliance with AWS Config

This lesson explains how AWS Config records the configuration of resources over time and evaluates it against rules, showing what changed and whether resources comply with policy.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe configuration items and history.
  • Explain how Config rules evaluate resources and trigger automatic remediation.
  • Identify the services built on AWS Config.

Recording configuration

AWS Config records a configuration item for each supported resource whenever it changes, building a timeline that shows how the resource was configured at any point in the past. It also records relationships between resources, such as which instances use a security group, which shows the impact of a change.

Combined with AWS CloudTrail, Config answers both what changed and who changed it: Config shows the resulting configuration, and CloudTrail shows the API call that made the change.

Rules and remediation

AWS Config checks resource configurations against rules. Managed rules are prebuilt checks, such as no security group allowing SSH from anywhere or every EBS volume being encrypted, and custom rules implement your own checks as Lambda functions or in the Guard policy language. Each resource is marked compliant or non-compliant whenever it changes or on a schedule.

Automatic remediation runs a Systems Manager Automation document to fix a non-compliant resource, such as enabling encryption on a bucket. Conformance packs deploy a collection of rules and remediations together, for example for PCI DSS, across accounts. Aggregators collect compliance data from many accounts and Regions into one view. The following table summarises the features.

FeatureUse
Managed rulesPrebuilt checks, such as no security group allowing 0.0.0.0/0 on port 22, or encrypted EBS volumes
Custom rulesYour own checks, written as Lambda functions or in Guard policy language
Automatic remediationSystems Manager Automation documents fix non-compliant resources
Conformance packsCollections of rules and remediations deployed together, such as for PCI DSS
AggregatorsCompliance across accounts and Regions in one view

The following diagram shows a rule detecting and fixing an open security group.

Automatic remediation with AWS Config. When a resource changes, Config evaluates it against its rules, such as no security group allowing SSH from anywhere. A non-compliant resource triggers a Systems Manager Automation document that fixes it, and the resource is evaluated again as compliant.
Config records what changed and who changed it; remediation fixes the resource but does not prevent the change.
Match the pairs

Config features

Exam skills 2.2.1 · 1.3.1

Match each requirement with the AWS Config feature that meets it.

Log in to try this activity Interactive activities are free with an account.

Config and other services

Several services are built on AWS Config: Control Tower's detective controls, AWS Security Hub CSPM's security checks and AWS Firewall Manager all rely on Config recording resource configurations, which is why Config must be enabled in every account and Region they cover.

Config is detective: it finds non-compliant resources after they are created and can remediate them. Preventive controls, such as service control policies, stop non-compliant actions from happening in the first place. Well-governed environments use both, preventing what can be prevented and detecting the rest.

Sort into groups

Preventive or detective?

Exam skills 1.1.4 · 2.2.1

Decide whether each control prevents or detects non-compliance.

Log in to try this activity Interactive activities are free with an account.
Worked example

Fixing open security groups automatically

Engineers keep opening SSH to the internet on security groups. The security team wants every such rule detected and removed within minutes, across all accounts.

ComponentRole
Config managed rule restricted-sshFlags security groups allowing 0.0.0.0/0 on port 22
Automatic remediationA Systems Manager Automation document removes the rule
Conformance pack deployed to the organisationApplies the rule in every account
Aggregator in the security accountOne compliance view across accounts and Regions

Config's timeline also shows what each group looked like before the change, and CloudTrail shows who made it.

Check yourself

Which service answers whether a resource complied with a rule last month?

Show answer

AWS Config, which records configuration history and evaluates resources against Config rules over time.

Exam Tips

Remember for the exam

  • For configuration history and compliance rules, use AWS Config.
  • To see what a resource's configuration looked like last week, use the AWS Config timeline.
  • To fix non-compliant resources automatically, use Config rules with Systems Manager Automation remediation.
  • To view compliance across all accounts, use a Config aggregator.