
I Tried Out the Proactive Controls Now Supported by CloudFormation / CDK
This page has been translated by machine translation. View original
Introduction
On November 30, 2026, AWS-managed proactive controls for AWS CloudFormation and AWS CDK were released for data protection and business continuity.
There are 88 controls, organized by resource type and change type, that check before a change whether a stack operation will delete or replace resources that hold data or that applications depend on. In this article, I try the control for DynamoDB tables with a change set that deletes a table in use.
Test environment
- Region: ap-northeast-1 (Tokyo)
- AWS CLI: 2.42.6
- CDK CLI: 2.1149.0
- aws-cdk-lib: 2.278.0
- Node.js: 22.23.3
Set the region for the commands to Tokyo with an environment variable or --region.
Prerequisites
AWS-managed proactive controls
You can get the list of controls with list-types.
aws cloudformation list-types --type HOOK --visibility PUBLIC --filters Category=AWS_MANAGED,TypeNamePrefix=AWS::Controls --query 'TypeSummaries[].TypeName' --output text | tr '\t' '\n' | sort
88 were returned in the Tokyo region. Here is an excerpt of the controls for major services.
AWS::Controls::DynamoDBTableInUseRemoved
AWS::Controls::DynamoDBTableInUseReplacementRequired
AWS::Controls::DynamoDBTableRemoved
AWS::Controls::DynamoDBTableReplacementRequired
AWS::Controls::EFSFileSystemInUseRemoved
AWS::Controls::IAMRoleInUseRemoved
AWS::Controls::KMSKeyRemoved
AWS::Controls::LambdaFunctionInUseRemoved
AWS::Controls::RDSDBClusterRemoved
AWS::Controls::RDSDBInstanceRemoved
AWS::Controls::S3BucketRemoved
AWS::Controls::SQSQueueInUseRemoved
List of all 88
AWS::Controls::AutoScalingAutoScalingGroupRemoved
AWS::Controls::AutoScalingAutoScalingGroupReplacementRequired
AWS::Controls::BackupBackupVaultRemoved
AWS::Controls::BackupBackupVaultReplacementRequired
AWS::Controls::CognitoUserPoolRemoved
AWS::Controls::DAXClusterInUseRemoved
AWS::Controls::DAXClusterInUseReplacementRequired
AWS::Controls::DAXClusterRemoved
AWS::Controls::DAXClusterReplacementRequired
AWS::Controls::DocDBDBClusterRemoved
AWS::Controls::DocDBDBClusterReplacementRequired
AWS::Controls::DocDBDBInstanceRemoved
AWS::Controls::DocDBDBInstanceReplacementRequired
AWS::Controls::DynamoDBGlobalTableRemoved
AWS::Controls::DynamoDBGlobalTableReplacementRequired
AWS::Controls::DynamoDBTableInUseRemoved
AWS::Controls::DynamoDBTableInUseReplacementRequired
AWS::Controls::DynamoDBTableRemoved
AWS::Controls::DynamoDBTableReplacementRequired
AWS::Controls::EC2VPCPeeringConnectionRemoved
AWS::Controls::EC2VPCPeeringConnectionReplacementRequired
AWS::Controls::EC2VolumeRemoved
AWS::Controls::ECSServiceReplacementRequiredChanges
AWS::Controls::EFSFileSystemInUseRemoved
AWS::Controls::EFSFileSystemInUseReplacementRequired
AWS::Controls::EFSFileSystemRemoved
AWS::Controls::EFSFileSystemReplacementRequired
AWS::Controls::ELBLoadBalancerInUseRemoved
AWS::Controls::ELBLoadBalancerInUseReplacementRequired
AWS::Controls::EMRClusterRemoved
AWS::Controls::EMRClusterReplacementRequired
AWS::Controls::ElastiCacheCacheClusterInUseRemoved
AWS::Controls::ElastiCacheCacheClusterInUseReplacementRequired
AWS::Controls::ElastiCacheCacheClusterRemoved
AWS::Controls::ElastiCacheCacheClusterReplacementRequired
AWS::Controls::ElastiCacheReplicationGroupRemoved
AWS::Controls::ElastiCacheReplicationGroupReplacementRequired
AWS::Controls::ElasticsearchDomainRemoved
AWS::Controls::ElasticsearchDomainReplacementRequired
AWS::Controls::EventsRuleInUseRemoved
AWS::Controls::EventsRuleInUseReplacementRequired
AWS::Controls::FSxFileSystemRemoved
AWS::Controls::FSxFileSystemReplacementRequired
AWS::Controls::IAMRoleInUseRemoved
AWS::Controls::IAMRoleInUseReplacementRequired
AWS::Controls::IAMRoleRemoved
AWS::Controls::IAMRoleReplacementRequired
AWS::Controls::KMSKeyRemoved
AWS::Controls::KinesisStreamInUseRemoved
AWS::Controls::KinesisStreamInUseReplacementRequired
AWS::Controls::KinesisStreamRemoved
AWS::Controls::KinesisStreamReplacementRequired
AWS::Controls::LambdaFunctionInUseRemoved
AWS::Controls::LambdaFunctionInUseReplacementRequired
AWS::Controls::LambdaVersionInUseRemoved
AWS::Controls::LambdaVersionInUseReplacementRequired
AWS::Controls::LogsLogGroupRemoved
AWS::Controls::LogsLogGroupReplacementRequired
AWS::Controls::NeptuneDBClusterRemoved
AWS::Controls::NeptuneDBClusterReplacementRequired
AWS::Controls::NeptuneDBInstanceRemoved
AWS::Controls::NeptuneDBInstanceReplacementRequired
AWS::Controls::QLDBLedgerRemoved
AWS::Controls::QLDBLedgerReplacementRequired
AWS::Controls::RDSDBClusterRemoved
AWS::Controls::RDSDBClusterReplacementRequired
AWS::Controls::RDSDBInstanceRemoved
AWS::Controls::RDSDBInstanceReplacementRequired
AWS::Controls::RedshiftClusterRemoved
AWS::Controls::RedshiftClusterReplacementRequired
AWS::Controls::Route53HostedZoneRemoved
AWS::Controls::Route53HostedZoneReplacementRequired
AWS::Controls::Route53ProfilesAssociationRemoved
AWS::Controls::Route53ResolverEndpointRemoved
AWS::Controls::S3BucketPolicyInUseRemoved
AWS::Controls::S3BucketPolicyInUseReplacementRequired
AWS::Controls::S3BucketPolicyRemoved
AWS::Controls::S3BucketPolicyReplacementRequired
AWS::Controls::S3BucketRemoved
AWS::Controls::S3BucketReplacementRequired
AWS::Controls::SDBDomainRemoved
AWS::Controls::SNSTopicInUseRemoved
AWS::Controls::SNSTopicInUseReplacementRequired
AWS::Controls::SQSQueueInUseRemoved
AWS::Controls::SQSQueueInUseReplacementRequired
AWS::Controls::SQSQueueRemoved
AWS::Controls::SQSQueueReplacementRequired
AWS::Controls::SecretsManagerSecretReplacementRequired
Default settings
The control that checks for deletion of a DynamoDB table in use is AWS::Controls::DynamoDBTableInUseRemoved. You can check the settings in your own environment with the following command.
aws cloudformation batch-describe-type-configurations --type-configuration-identifiers Type=HOOK,TypeName=AWS::Controls::DynamoDBTableInUseRemoved
In the account I tested, HookInvocationStatus was ENABLED and FailureMode was WARN, as shown below.
{
"Errors": [],
"UnprocessedTypeConfigurations": [],
"TypeConfigurations": [
{
"Arn": "arn:aws:cloudformation:ap-northeast-1::type-configuration/hook/AWS-Controls-DynamoDBTableInUseRemoved/default",
"Alias": "default",
"Configuration": "{\"CloudFormationConfiguration\":{\"HookConfiguration\":{\"HookInvocationStatus\":\"ENABLED\",\"FailureMode\":\"WARN\",\"TargetOperations\":[\"CHANGE_SET\",\"STACK\"],\"Properties\":{}}}}",
"LastUpdated": "2026-11-12T20:43:52.065000+00:00"
}
]
}
Determining "in use"
A DynamoDB table is determined to be in use if it has had activity in the last 24 hours.
The DeletionPolicy of the test table is Delete (the default). The determination requires the IAM permission cloudwatch:GetMetricData.
Verification with CloudFormation
Test stack
Create a stack containing only a DynamoDB table and an SSM parameter.
template-with-table.yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: proactive controls verification (DynamoDB table + SSM parameter)
Resources:
DemoTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: devio-pc-demo-table
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
DemoParam:
Type: AWS::SSM::Parameter
Properties:
Type: String
Value: demo
template-without-table.yaml is the template above with the DemoTable block removed and the Description changed.
aws cloudformation create-stack --stack-name devio-pc-demo --template-body file://template-with-table.yaml
aws cloudformation wait stack-create-complete --stack-name devio-pc-demo
After creating the stack, to make the table "in use", I ran put-item and get-item three times each (item-1 to item-3). The following is the example for item-1.
aws dynamodb put-item --table-name devio-pc-demo-table --item '{"pk":{"S":"item-1"}}'
aws dynamodb get-item --table-name devio-pc-demo-table --key '{"pk":{"S":"item-1"}}'
Creating a change set
Create an update change set with the template that has the table removed. After waiting for creation, check the finding with describe-events.
aws cloudformation create-change-set --stack-name devio-pc-demo --change-set-name remove-table-2 --change-set-type UPDATE --template-body file://template-without-table.yaml
aws cloudformation wait change-set-create-complete --stack-name devio-pc-demo --change-set-name remove-table-2
aws cloudformation describe-events --stack-name devio-pc-demo --change-set-name remove-table-2
When I created this change set about 2 minutes 47 seconds after the last access, a finding appeared in the output of describe-events.
Contents of the finding
The following is the finding event extracted from the describe-events output of remove-table-2. The account ID in StackId is replaced with 123456789012, and the UUID of each ID is replaced with <id>.
{
"EventId": "<id>",
"StackId": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/devio-pc-demo/<id>",
"OperationId": "<id>",
"OperationType": "CREATE_CHANGESET",
"EventType": "VALIDATION_ERROR",
"LogicalResourceId": "DemoTable",
"PhysicalResourceId": "",
"ResourceType": "AWS::DynamoDB::Table",
"Timestamp": "2026-11-30T08:11:22.354000+00:00",
"ValidationFailureMode": "WARN",
"ValidationName": "DYNAMODB_TABLE_IN_USE_REMOVED | AWS::Controls::DynamoDBTableInUseRemoved",
"ValidationStatus": "FAILED",
"ValidationStatusReason": "Removing DynamoDB table DemoTable deletes the table and its data. The table consumed read or write capacity in the last 24 hours.",
"ValidationPath": "/Resources/DemoTable/DeletionPolicy"
}
You can tell the target table from LogicalResourceId and the reason from ValidationStatusReason.
Switching modes
There are two modes, Warn and Fail, and you can also disable the control. Here I switch from Warn to Fail.
Fail configuration
What I changed from the Warn configuration was setting FailureMode to FAIL and adding StackFilters. With StackFilters, I limited the evaluation target to only the test stack devio-pc-demo. Save the modified configuration as hook-config-fail.json and apply it.
{
"CloudFormationConfiguration": {
"HookConfiguration": {
"HookInvocationStatus": "ENABLED",
"FailureMode": "FAIL",
"TargetOperations": [
"CHANGE_SET",
"STACK"
],
"Properties": {},
"StackFilters": {
"FilteringCriteria": "ALL",
"StackNames": {
"Include": [
"devio-pc-demo"
]
}
}
}
}
}
aws cloudformation set-type-configuration --type HOOK --type-name AWS::Controls::DynamoDBTableInUseRemoved --configuration file://hook-config-fail.json
Fail result
After switching to Fail, I created the change set remove-table-fail with the same template.
aws cloudformation create-change-set --stack-name devio-pc-demo --change-set-name remove-table-fail --change-set-type UPDATE --template-body file://template-without-table.yaml
aws cloudformation wait change-set-create-complete --stack-name devio-pc-demo --change-set-name remove-table-fail
aws cloudformation describe-change-set --stack-name devio-pc-demo --change-set-name remove-table-fail --query '{Status:Status,StatusReason:StatusReason}'
Creation of the change set failed, and Status became FAILED.
{
"Status": "FAILED",
"StatusReason": "Validation failed with 1 error(s). Call DescribeEvents for details."
}
When I ran describe-events, a finding with ValidationFailureMode FAIL appeared.
Verification with CDK
The control's configuration can be written in CDK as AWS::CloudFormation::HookTypeConfig. In the following CDK app, this configuration and the table are defined in a single stack, devio-pc-cdk2. The environment variable FAILURE_MODE switches the mode, and WITH_TABLE switches whether the table exists. HookTypeConfig overwrites the configuration of this control in the account.
app.js
const cdk = require('aws-cdk-lib');
const cloudformation = require('aws-cdk-lib/aws-cloudformation');
const dynamodb = require('aws-cdk-lib/aws-dynamodb');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'devio-pc-cdk2', {
env: { region: 'ap-northeast-1' },
synthesizer: new cdk.DefaultStackSynthesizer(),
});
// Fail with FAILURE_MODE=FAIL, otherwise Warn
const failureMode = process.env.FAILURE_MODE === 'FAIL' ? 'FAIL' : 'WARN';
new cloudformation.CfnHookTypeConfig(stack, 'DynamoDBTableInUseRemovedConfig', {
typeName: 'AWS::Controls::DynamoDBTableInUseRemoved',
configuration: JSON.stringify({
CloudFormationConfiguration: {
HookConfiguration: {
HookInvocationStatus: 'ENABLED',
FailureMode: failureMode,
TargetOperations: ['CHANGE_SET', 'STACK'],
Properties: {},
StackFilters: {
FilteringCriteria: 'ALL',
StackNames: { Include: ['devio-pc-cdk2'] },
},
},
},
}),
});
// Define the table only when WITH_TABLE=1 (removing it causes deletion)
if (process.env.WITH_TABLE === '1') {
new dynamodb.Table(stack, 'DemoTable', {
tableName: 'devio-pc-cdk2-table',
partitionKey: { name: 'pk', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
}
The app in cdk.json is node app.js. Install the dependency packages with the following command.
npm install aws-cdk aws-cdk-lib constructs
Finding in Warn mode
I deployed the stack with the table under the Warn configuration, then ran put-item and get-item three times each on the table devio-pc-cdk2-table. About 3 minutes after the last access, I ran cdk deploy with --method=prepare-change-set without defining the table, and checked describe-events for the change set.
WITH_TABLE=1 FAILURE_MODE=WARN npx cdk deploy --require-approval never
FAILURE_MODE=WARN npx cdk deploy --method=prepare-change-set --require-approval never
aws cloudformation describe-events --stack-name devio-pc-cdk2 --change-set-name cdk-deploy-change-set --query 'OperationEvents[].{Type:EventType,Name:ValidationName,Mode:ValidationFailureMode,Status:ValidationStatus,Reason:ValidationStatusReason,Time:Timestamp}'
The finding was not displayed in the output of cdk deploy; it appeared in describe-events. The finding event is the following single one.
{
"Type": "VALIDATION_ERROR",
"Name": "DYNAMODB_TABLE_IN_USE_REMOVED | AWS::Controls::DynamoDBTableInUseRemoved",
"Mode": "WARN",
"Status": "FAILED",
"Reason": "Removing DynamoDB table DemoTableEE720AED deletes the table and its data. The table consumed read or write capacity in the last 24 hours.",
"Time": "2026-11-30T13:26:12.043000+00:00"
}
Stopped by Fail
I deleted the change set, set FAILURE_MODE to FAIL, and deployed the stack. Then I ran a normal cdk deploy without defining the table.
aws cloudformation delete-change-set --stack-name devio-pc-cdk2 --change-set-name cdk-deploy-change-set
WITH_TABLE=1 FAILURE_MODE=FAIL npx cdk deploy --require-approval never
FAILURE_MODE=FAIL npx cdk deploy --require-approval never
The second cdk deploy ended with a failure to create the change set. The finding was displayed in the output.
devio-pc-cdk2: creating CloudFormation changeset...
Failed to create change set cdk-deploy-change-set:
devio-pc-cdk2/DemoTableEE720AED (AWS::DynamoDB::Table DemoTableEE720AED)
Removing DynamoDB table DemoTableEE720AED deletes the table and its data. The table consumed read or write capacity in
the last 24 hours. (at /Resources/DemoTableEE720AED/DeletionPolicy)
When I checked with describe-table, the table remained ACTIVE.
Deleting the stack
Return to Warn and then delete the stack.
WITH_TABLE=1 FAILURE_MODE=WARN npx cdk deploy --require-approval never
npx cdk destroy --force
After deleting the stack, the control's HookInvocationStatus became DISABLED. Restore the default ENABLED / WARN with the following command.
aws cloudformation set-type-configuration --type HOOK --type-name AWS::Controls::DynamoDBTableInUseRemoved --configuration '{"CloudFormationConfiguration":{"HookConfiguration":{"HookInvocationStatus":"ENABLED","FailureMode":"WARN","TargetOperations":["CHANGE_SET","STACK"],"Properties":{}}}}'
Summary
For AWS-managed proactive controls, I was able to confirm the behavior when deleting resources with CloudFormation and CDK.
When DeletionPolicy is set to Retain to avoid accidental deletion, unused and unnecessary resources may also be left behind. With Fail mode, you can reduce the risk of accidentally deleting resources in use while still deleting the whole stack if the resources are unused.
If you create important resources with CloudFormation or CDK and manage updates with IaC as well, please try this update as a mechanism to reduce the risk of missed deletions and accidents.
