Lesson 3 of 5 AWS Config and AWS AppConfig

Remediating Non-Compliant Resources Automatically

Detecting non-compliance is only half of the job; a resource that stays non-compliant remains a risk. This lesson explains how AWS Config remediation actions run Systems Manager Automation runbooks manually or automatically, how EventBridge-based remediation extends this to any response, and how to design remediations that are safe, idempotent and auditable.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain how Config remediation actions use Systems Manager Automation runbooks and the parameters they receive.
  • Distinguish between manual and automatic remediation and explain retry settings.
  • Describe EventBridge-based remediation for compliance changes and when to use it.
  • Explain how remediation is defined as code, rate-limited with execution controls and applied across an organisation.
  • Identify remediations that cannot be performed in place and design alternatives.

Remediation Actions

A Config rule can have a remediation action: a Systems Manager Automation runbook that Config runs for a non-compliant resource. AWS provides runbooks for many common fixes, with names such as AWS-DisableS3BucketPublicReadWrite, AWS-EnableS3BucketEncryption, AWSConfigRemediation-RemoveUnrestrictedSourceIngressRules, AWSConfigRemediation-EnableCloudTrailLogFileValidation, AWSConfigRemediation-DeleteUnusedEBSVolume and AWS-PublishSNSNotification. Custom runbooks can implement any other fix.

Runbook parameters can be static values or the special value RESOURCE_ID, which Config replaces with the ID of the non-compliant resource. The runbook usually takes an AutomationAssumeRole parameter: the ARN of a role that the automation assumes and that has permission to make the fix. Without that role, or with insufficient permissions, the remediation fails, and the failure is visible in the rule's remediation status and in the Automation execution history.

Manual and Automatic Remediation

With manual remediation, an operator selects non-compliant resources and starts the remediation. It suits changes that need judgement, such as stopping an instance. With automatic remediation, Config starts the runbook as soon as a resource is evaluated as non-compliant. Automatic remediation has retry settings: the maximum number of attempts and the period in seconds over which they are counted. If a resource keeps returning to non-compliance, for example because a deployment pipeline or a person keeps reverting the fix, the attempts are exhausted and the conflict becomes visible, which signals that the root cause must be fixed elsewhere.

Remediate safely

Automatic remediation changes resources without human review. Test runbooks in a non-production OU, scope them carefully and make sure they cannot cause outages, for example by removing a security group rule that production traffic depends on without an exception mechanism such as a tag.

EventBridge-Based Remediation

Config publishes a Config Rules Compliance Change event to EventBridge whenever a resource's compliance changes. An EventBridge rule can match non-compliant results for particular rules and send them to any target: a Lambda function, a Step Functions state machine for multi-step responses with approvals, an SSM Automation runbook, an SNS topic or a ticketing integration. EventBridge-based remediation suits responses that remediation actions cannot express, such as notifying a resource owner found from a tag, opening an OpsCenter OpsItem, waiting for an approval or remediating across accounts from a central account by forwarding events to a central event bus.

Config remediation action
RunsOne SSM Automation runbook
Configured onThe Config rule (also in conformance packs)
Retries and statusBuilt-in retry settings and remediation status
Best forDirect, single-resource fixes
Choose when A runbook fix exists and should run per resource.
EventBridge rule
RunsAny EventBridge target
Configured onAn EventBridge rule matching compliance events
Retries and statusDepends on the target; use DLQs and retries
Best forNotifications, workflows, central or cross-account responses
Choose when The response needs logic, approvals or central processing.

The following diagram compares the two remediation paths.

Two remediation paths from AWS Config. A remediation action on the rule runs one Systems Manager Automation runbook for the non-compliant resource, passing RESOURCE_ID and an AutomationAssumeRole, with built-in retries and status. Every compliance change is also published to EventBridge, where a rule can start any target, such as a Lambda function, a Step Functions workflow with approvals, an SNS notification, an OpsItem or a central event bus in another account.
Both paths start from the same compliance evaluation.

Defining Remediation as Code Across an Organisation

A remediation action is a separate resource attached to a rule, so it can be defined in CloudFormation with AWS::Config::RemediationConfiguration. The example below attaches automatic remediation to a rule that detects S3 buckets that allow public write access.

PublicWriteRemediation:
  Type: AWS::Config::RemediationConfiguration
  Properties:
    ConfigRuleName: s3-bucket-public-write-prohibited
    TargetType: SSM_DOCUMENT
    TargetId: AWS-DisableS3BucketPublicReadWrite
    Automatic: true
    MaximumAutomaticAttempts: 3
    RetryAttemptSeconds: 60
    ExecutionControls:
      SsmControls:
        ConcurrentExecutionRatePercentage: 10   # remediate at most 10% of resources at once
        ErrorPercentage: 10                     # stop if more than 10% of executions fail
    Parameters:
      S3BucketName:
        ResourceValue:
          Value: RESOURCE_ID
      AutomationAssumeRole:
        StaticValues:
          Values: [arn:aws:iam::111122223333:role/ConfigRemediationRole]

The execution controls are an important safety mechanism. When a rule is first deployed, hundreds of existing resources can be non-compliant at once, and automatic remediation would change them all simultaneously. A concurrency percentage limits how many run at the same time, and an error percentage stops the remediation when a faulty runbook starts failing, before it touches every resource.

To apply the same remediation in every account, the rule and its remediation configuration are placed in a conformance pack template and deployed as an organisation conformance pack from the management account or a delegated administrator. Each member account then needs what the runbook depends on. AWS-owned runbooks exist everywhere, but a custom runbook must be shared with the member accounts or deployed to them, and the AutomationAssumeRole must exist in each account, usually created by a CloudFormation StackSet with service-managed permissions so that new accounts receive it automatically. A missing role in one account is a common reason why remediation works in some accounts but not others.

Remediations That Cannot Be Done in Place

Some non-compliance cannot be fixed by changing the resource. An unencrypted EBS volume cannot be encrypted in place; it must be snapshotted, the snapshot copied with encryption and a new volume created and attached, which needs downtime and a custom runbook, so most organisations prevent the problem instead by enabling EBS encryption by default in every account and Region. Similarly, an unencrypted RDS instance cannot be encrypted in place and must be restored from an encrypted snapshot copy. For these cases, the right design combines prevention (account defaults, SCPs, hooks) with detection and a notification or ticket rather than automatic remediation.

Scenario questions

Remediate safely

Exam skills 4.3.6 · 5.2.3

Practise designing and troubleshooting Config remediation.

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

Closing Open SSH Access Automatically

Developers occasionally add inbound rules allowing SSH from 0.0.0.0/0 to security groups in development accounts. Security wants such rules removed within minutes, wants the developer notified, and wants security groups tagged AllowPublicSsh=approved to be excluded.

  1. Detect

    Deploy the managed restricted-ssh rule through an organisation conformance pack.

  2. Remediate

    Add automatic remediation with AWSConfigRemediation-RemoveUnrestrictedSourceIngressRules (or a custom runbook that first checks the exception tag), RESOURCE_ID as the group ID, an AutomationAssumeRole and three attempts in 300 seconds.

  3. Notify

    An EventBridge rule on the compliance change event invokes a Lambda function that looks up the CloudTrail event for the change and messages the developer who made it.

Check yourself

A Config automatic remediation keeps failing with an access denied error in the Automation execution. What should be checked first?

Show answer

The role passed as AutomationAssumeRole: it must exist, trust ssm.amazonaws.com and have permission to perform the fix on the resource.

Exam Tips

Remember for the exam

  • Config remediation actions run SSM Automation runbooks with RESOURCE_ID and an AutomationAssumeRole; automatic remediation has retry attempts within a period.
  • Use EventBridge rules on Config Rules Compliance Change events for notifications, workflows and central or cross-account remediation.
  • Some issues, such as unencrypted EBS volumes or RDS instances, cannot be fixed in place; prevent them with account defaults and preventive controls.
  • Remediation that keeps recurring indicates a conflicting process, such as IaC reverting the fix.
  • Define remediation with AWS::Config::RemediationConfiguration; execution controls limit concurrency and stop on errors; organisation conformance packs need the runbook and AutomationAssumeRole in every account.