Certopolis

AWS Certified DevOps Engineer – Professional

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.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An AWS Config rule in a company's production account flags Amazon S3 buckets that allow public read or write access. The security team wants every flagged bucket fixed by turning on S3 Block Public Access for it, and it wants the fix to come from an AWS managed procedure rather than from code that the team writes. The team reviews the rule's compliance results every week and expects the flagged buckets to be fixed without anyone acting. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Incident and Event Response building.

    Not that one: A is right. In the game your Incident and Event Response building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    AWS-DisableS3BucketPublicReadWrite is an AWS managed runbook that turns on S3 Block Public Access for the bucket it is given, so attaching it to the rule, with the bucket supplied for each noncompliant resource, fixes every flagged bucket without team-written code.

    Written from docs.aws.amazon.com/config/latest/developerguide/remediation.html

  2. A DevOps team deploys its AWS Config rules and their remediation actions from an AWS CloudFormation template through a pipeline. One rule flags Amazon EC2 instances that lack the company's required tags. Its automatic remediation runs a custom Automation runbook with two parameters: InstanceId, the instance to fix, and AutomationAssumeRole, the ARN of a role in the same account that the runbook runs as. Each remediation run must act on the instance that the rule flagged, and every run must use that one role. How should the DevOps engineer write the Parameters property of the AWS::Config::RemediationConfiguration resource to meet these requirements?

    Right. In the game that’s Renown for your Incident and Event Response building.

    Not that one: D is right. In the game your Incident and Event Response building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    AutomationAssumeRole does not change between runs, so it is a StaticValue whose Values list holds the role's ARN.

    Written from docs.aws.amazon.com/config/latest/developerguide/setup-autoremediation.html

  3. A company's AWS Config rule, built on the required-tags managed rule, has flagged Amazon EBS volumes that lack the CostCenter tag for several months, and 300 existing volumes are noncompliant today. New untagged volumes still appear every week. The platform team has a custom AWS Systems Manager Automation runbook that takes a volume in its required VolumeId parameter, accepts an optional InstanceId parameter, and copies the CostCenter tag from the instance the volume is attached to. Every noncompliant volume, the 300 already flagged and each future one, must be tagged by that runbook without anyone starting it by hand. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Incident and Event Response building.

    Not that one: B is right. In the game your Incident and Event Response building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Choosing VolumeId as the resource ID parameter makes Config put each flagged volume's ID into that parameter at run time. So the 300 volumes already on the list are tagged, and each new untagged volume is tagged after its first evaluation. Starting another evaluation afterwards is harmless; the remediation does not depend on it.

    Written from docs.aws.amazon.com/config/latest/developerguide/setup-autoremediation.html

Ask for something