AWS Config auto remediation with SSM Automation (DOP-C02)
AWS Config fixes noncompliant resources through remediation actions attached to a rule. The AWS Config Developer Guide says each action is a Systems Manager Automation document, either AWS managed or your own, and can run manually or automatically. A resource ID parameter passes the noncompliant resource's ID to the document at run time.
What is a remediation action?
A remediation action associates an SSM Automation document with an AWS Config rule. The document defines what is done to a resource that the rule evaluates as noncompliant. AWS Config provides managed automation documents, and you can associate custom ones.
One managed example is AWS-DisableS3BucketPublicReadWrite, which uses S3 Block Public Access to disable read and write access for a public bucket. It takes the required S3BucketName parameter and an optional AutomationAssumeRole, the IAM role that lets Systems Manager Automation act on your behalf.
Remediations can be managed only for rules that are not service-linked.
Manual vs automatic remediation
Every remediation action is set to manual or automatic. With manual remediation someone starts the action for a noncompliant resource. With automatic remediation AWS Config starts it.
Enabling auto remediation on a rule starts remediation for all resources that the rule currently reports as noncompliant, not only for resources that fail later. The process relies on a compliance snapshot captured periodically, so it can occasionally run against a resource that has since become compliant.
If a resource is still noncompliant after auto remediation, the rule can retry. MaximumAutomaticAttempts defaults to 5 and RetryAttemptSeconds defaults to 60 seconds. When the attempts are used up inside that window, AWS Config adds a remediation exception to the resource so that it does not retry forever. describe-remediation-execution-status shows the state and error messages of each step.
How are parameters passed to the document?
Each parameter has either a static value or a dynamic value. In the console you choose one parameter as the Resource ID parameter. At run time AWS Config substitutes the ID of the resource being remediated for it. All other parameters take the values you enter.
In the API and in CloudFormation the same choice appears in the Parameters map of AWS::Config::RemediationConfiguration. A dynamic value is a ResourceValue whose Value is RESOURCE_ID, the only valid value. Fixed inputs, such as a role ARN, are static values.
The CloudFormation resource also sets TargetType, whose only allowed value is SSM_DOCUMENT, TargetId, which is the name of the SSM document, and the Boolean Automatic.
Where the exam catches people
Believing AWS Config runs a Lambda function as its remediation action: remediation targets are SSM Automation documents.
Believing auto remediation handles only resources that become noncompliant later: turning it on starts remediation for every resource the rule already reports as noncompliant.
Believing the document is told which resource to fix automatically: one parameter must be set as the resource ID parameter, RESOURCE_ID.
Believing the role ARN should be a dynamic value: only the resource ID is dynamic. The role is a static value.
Believing auto remediation retries without limit: after the maximum attempts in the retry window, AWS Config adds a remediation exception.