

# Data protection and business continuity controls

Data protection and business continuity controls help developers and AI agents prevent common deployment mistakes. They check whether a stack operation deletes or replaces a resource that stores data your applications use or that your applications depend on. AWS builds the controls from the checks that AWS runs on its own infrastructure. For security and compliance requirements, AWS provides proactive controls from the Control Catalog. For more information, see [Security and compliance controls from the Control Catalog](proactive-controls-control-catalog.md).

Each control has a type name that starts with `AWS::Controls::`, which you use with the AWS CLI. The controls are available at no additional charge in all AWS Regions where CloudFormation is supported, except the AWS China Regions.

For a comparison of the two groups of AWS-managed proactive controls, see [AWS-managed proactive controls](proactive-controls-hooks.md).

## What the controls check
<a name="aws-managed-proactive-controls-what-they-check"></a>

The controls check stack operations that run through CloudFormation, before any resource changes. This includes AWS Cloud Development Kit (AWS CDK) and AWS Serverless Application Model deployments, change sets, and create, update, and delete operations. When you enable a control, it evaluates the stack operations that run after you enable it.

Controls that check whether a resource is still in use read the activity of the resource over a fixed window:
+ The last 24 hours for most resource types.
+ The last 7 days for IAM roles and Amazon S3 bucket policies.

When a resource has `DeletionPolicy` or `UpdateReplacePolicy` set to `Retain`, CloudFormation keeps the resource, and the control reports no finding.

## Controls enabled by default
<a name="aws-managed-proactive-controls-default-state"></a>

Data protection controls that check whether a resource is still in use are enabled by default in `WARN` mode in every account. You enable the other controls.

## Control modes
<a name="aws-managed-proactive-controls-modes"></a>

Each control has one of the following modes:
+ `WARN`: The control reports the finding and lets the operation continue.
+ `FAIL`: The control stops the operation before any resource changes.
+ Disabled: The control is inactive.

If a control can't finish a check, a `FAIL` control stops the operation, and a `WARN` control lets the operation continue.

## Permissions to read resource activity
<a name="aws-managed-proactive-controls-before-you-start"></a>

The controls read activity with the credentials of the caller, for example Amazon CloudWatch metrics and IAM role last-used data. The permissions are the same whether a control is enabled by default or enabled by you.
+ Controls that check whether a resource is still in use read CloudWatch metrics with `cloudwatch:GetMetricData`.
+ The IAM role in-use control reads IAM role last-used data with `iam:GetRole`.

If the caller can't read the activity of a resource, a `FAIL` control stops the operation and names the missing permission, and a `WARN` control lets the operation continue.

The following example policy statement allows the actions that the controls use.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "cloudwatch:GetMetricData",
        "iam:GetRole"
      ],
      "Resource": "*"
    }
  ]
}
```

You aren't charged for the CloudWatch calls that the controls make.

## Enable, disable, or change the mode of a control
<a name="aws-managed-proactive-controls-configure"></a>

You can enable or disable a control and change its mode on the CloudFormation console or with the AWS CLI.

### Enable, disable, or change the mode of a control (console)
<a name="aws-managed-proactive-controls-configure-console"></a>

**To enable, disable, or change the mode of a control**

1. Sign in to the AWS Management Console and open the CloudFormation console at [https://console.aws.amazon.com/cloudformation](https://console.aws.amazon.com/cloudformation/).

1. On the navigation bar at the top of the screen, choose the AWS Region where you want to manage the control.

1. In the navigation pane on the left, choose **Hooks**.

1. On the **Hooks** page, find the control in the proactive controls table.

1. Enable or disable the control, and set its mode to `WARN` or `FAIL`.

### Enable, disable, or change the mode of a control (AWS CLI)
<a name="aws-managed-proactive-controls-configure-cli"></a>

**To enable, disable, or change the mode of a control (AWS CLI)**

1. To list the controls, use the following [list-types](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/list-types.html) command.

   ```
   aws cloudformation list-types \
     --type HOOK \
     --visibility PUBLIC \
     --filters Category=AWS_MANAGED,TypeNamePrefix=AWS::Controls
   ```

1. To enable a control and set its mode, use the following [set-type-configuration](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/set-type-configuration.html) command. This example enables the `AWS::Controls::IAMRoleInUseRemoved` control in `FAIL` mode.

   ```
   aws cloudformation set-type-configuration \
     --type HOOK \
     --type-name AWS::Controls::IAMRoleInUseRemoved \
     --configuration '{"CloudFormationConfiguration":{"HookConfiguration":{"HookInvocationStatus":"ENABLED","FailureMode":"FAIL"}}}'
   ```

   To disable a control, set `HookInvocationStatus` to `DISABLED`. For more information about the configuration schema, see [Hook configuration schema syntax reference](hook-configuration-schema.md).

### Apply a control to specific stacks
<a name="aws-managed-proactive-controls-configure-stackfilters"></a>

To apply a control to specific stacks, add `StackFilters` to the configuration. A control evaluates only the stacks that match its stack filter. The following example applies a control to the stack named `OrdersStack`.

```json
"StackFilters": {
  "FilteringCriteria": "ALL",
  "StackNames": {
    "Include": ["OrdersStack"]
  }
}
```

For more information about stack level filters, see [CloudFormation Hooks stack level filters](hooks-stack-level-filtering.md).

The following topics describe how to use the controls.

**Topics**
+ [What the controls check](#aws-managed-proactive-controls-what-they-check)
+ [Controls enabled by default](#aws-managed-proactive-controls-default-state)
+ [Control modes](#aws-managed-proactive-controls-modes)
+ [Permissions to read resource activity](#aws-managed-proactive-controls-before-you-start)
+ [Enable, disable, or change the mode of a control](#aws-managed-proactive-controls-configure)
+ [View findings from controls](aws-managed-proactive-controls-findings.md)
+ [Override controls for an operation](aws-managed-proactive-controls-proceed.md)
+ [Use controls with AI agents](aws-managed-proactive-controls-ai-agents.md)
+ [Enable controls across an organization](aws-managed-proactive-controls-organization.md)