DynamoDB Deletion Protection: How to Enable and Verify It

Written by Rafal Wilinski
Published: November 20th, 2026
To prevent accidental DynamoDB table deletion, set DeletionProtectionEnabled to true when you create or update the table. DynamoDB then rejects DeleteTable even for an administrator with permission to call it. Authorized item deletes and Time to Live (TTL) expiration still work. For a global table, enable and verify the setting on each replica. AWS deletion protection guide, AWS global table guidance.
What DynamoDB deletion protection covers
The flag defaults to off, including on new replicas and tables restored from backups. A planned deletion takes two steps: an authorized principal turns protection off with UpdateTable, then a principal with dynamodb:DeleteTable can delete the DynamoDB table. The setting guards normal table management calls. AWS also documents that closing an account can still lead to table deletion and that DynamoDB can archive a table if it loses access to its customer managed encryption key. AWS table operations, UpdateTable API.
Your application can still use DeleteItem or send delete requests in BatchWriteItem if its role is allowed to do so. TTL still removes expired items on tables where it is enabled. Use IAM to restrict destructive writes and backups to recover from unwanted data changes.
Does it protect global table replicas?
Yes. Deletion protection belongs to the individual replica, and DynamoDB configures it independently even for multi-account global tables. Set it in every replica Region, using credentials for the owning account, and check each Region after you add a replica. For CloudFormation global tables, set DeletionProtectionEnabled: true on each entry in Replicas. Same-account settings, multi-account settings, CloudFormation replica properties.
Enable and check DynamoDB deletion protection
Select the intended AWS account and Region before running the examples. The CLI, SDK, and Terraform examples use an on-demand table named Orders with a string partition key called orderId.
AWS Management Console
- New table. In DynamoDB, choose Tables → Create table, enter the table details, choose Customize settings, and turn on Deletion protection before creating it. AWS console walkthrough.
- Existing table. Open the table, choose Additional settings, and enable protection in the Deletion protection panel. Check the same panel after saving. AWS DynamoDB Developer Guide.
AWS CLI v2
Use --deletion-protection-enabled with create-table to protect a new table.
For an existing table, use update-table.
Wait for the table to become ACTIVE, then check the live value. The expected output is true. For a global table, repeat the check with --region set to each replica's Region. AWS CLI waiter, DescribeTable result fields.
AWS SDK for JavaScript v3
Use the low-level @aws-sdk/client-dynamodb client. Run one of CreateTableCommand or UpdateTableCommand, then check with DescribeTable after the table is active.
Save it as protect-orders.mjs. Run node protect-orders.mjs --create for a new table or node protect-orders.mjs for an existing one. See the AWS SDK waiter example.
Python with boto3
Pass DeletionProtectionEnabled=True to create_table or update_table. Save as protect_orders.py and use --create only for a new table.
CloudFormation
Set DeletionProtectionEnabled under Properties on AWS::DynamoDB::Table. For an existing stack-managed table, add the property to the existing logical resource and deploy a stack update. AWS documents this change as No interruption. The two retention attributes in this example are separate safeguards, explained below. AWS table resource reference, DynamoDB CloudFormation examples.
AWS CDK v2
Set deletionProtection: true on Table when you define it. For an existing CDK-managed table, change the property on the same construct and deploy the existing stack. For TableV2 global tables, configure deletionProtection for the primary and in each replica's settings. CDK TableProps, CDK DynamoDB construct reference.
Terraform
Set deletion_protection_enabled = true on aws_dynamodb_table. For an existing table already in Terraform state, add it to that resource, check that terraform plan shows an in-place update, and apply. The AWS provider sends the flag in UpdateTable when this argument changes. HashiCorp AWS provider reference, provider update implementation.
Restrict who can turn deletion protection off
DeletionProtectionEnabled is an API field. The DynamoDB IAM authorization reference lists no condition key that lets IAM distinguish true from false on dynamodb:UpdateTable. The aws:ResourceTag condition can scope a rule to selected tables. The rule still governs the whole action, including changes to throughput, indexes, and streams. AWS guidance on table guardrails.
- Give application roles only the item operations they need. Reserve
dynamodb:UpdateTablefor a controlled maintenance or deployment role scoped to the required table ARNs. Givedynamodb:DeleteTableonly to the role responsible for approved deletions. Review who can invoke CloudFormation stack updates too, because a stack can use its configured service role on the caller's behalf. DynamoDB access control, CloudFormation service roles. - For an explicit guardrail across a member account, use an AWS Organizations service control policy (SCP). For example, deny
dynamodb:UpdateTableon the production table ARN unlessaws:PrincipalArnmatches your approved maintenance role's IAM ARN. Add an independently scoped deny fordynamodb:DeleteTableif deletion has a different approval path. An SCP limits permissions. The excepted role still needs an IAM allow, and management-account principals and service-linked roles are outside SCP restrictions. SCP scope, IAM principal ARN condition. - A DynamoDB table resource policy can add an explicit deny on
UpdateTableorDeleteTablefor unwanted principals. If you use table tags to select protected resources, also restrict who can change those tags. Review the replica-management actions and replica ARNs for global tables. Supported resource-policy actions, AWS global tables IAM guidance.
Verify the setting and the permission separately
On a disposable table covered by the same rules, try update-table --no-deletion-protection-enabled as the application role. Expect an access-denied response and confirm that DescribeTable still shows true. Verify that the authorized maintenance role can change the setting and re-enable it. Test IAM against the real policies and role sessions. AWS documents simulator limits for conditional SCPs and resource policies on roles. Check the Region's CloudTrail management events for UpdateTable, including the caller and request parameters. Audit the live setting at scale with Security Hub control DynamoDB.6 or the AWS Config rule dynamodb-table-deletion-protection-enabled. IAM policy simulator, DynamoDB CloudTrail events, Security Hub controls.
CloudFormation and CDK stack deletion
| Setting | Effect |
|---|---|
DeletionProtectionEnabled: true | DynamoDB rejects a delete request from any caller, including CloudFormation. AWS table resource reference |
DeletionPolicy: Retain | CloudFormation keeps the physical table when you delete the stack or remove the resource from the template. DeletionPolicy |
UpdateReplacePolicy: Retain | CloudFormation keeps the old physical table if a stack update replaces it. UpdateReplacePolicy |
CDK RemovalPolicy.RETAIN | For the Table above, CDK synthesizes both retention attributes. Check them with cdk synth. CDK resource policies, CDK implementation |
If CloudFormation tries to delete a protected table, DynamoDB rejects the request and the stack can reach DELETE_FAILED. Other resources may already have been deleted. To finish the stack deletion and keep the table, choose Retry delete → Delete this stack but retain resources and select the table, or retry with the table's logical ID in RetainResources. If the table itself is meant to be deleted, disable protection as an authorized role before retrying. For planned stack teardown that should preserve data, declare Retain while the stack is still healthy. AWS stack deletion procedure, CloudFormation troubleshooting.
What error do you see when deleting a protected table?
AWS documents this CLI response to aws dynamodb delete-table --table-name Orders when the caller has delete permission and protection is enabled. AWS re:Post Knowledge Center.
Confirm the protection flag with DescribeTable. If you see an access-denied error, check the caller's effective IAM permissions, the resource policy, and any applicable SCP. AWS IAM evaluation logic.
Layered protection checklist
- Deletion protection. Enable it in infrastructure code on production tables and verify the live value in every replica Region. AWS global table guidance.
- PITR. Turn on DynamoDB point-in-time recovery to recover from accidental item deletes and bad writes. The continuous recovery window is configurable from 1 to 35 days while the source table exists. AWS PITR reference.
- AWS Backup. Schedule backups with a retention period that meets your recovery requirements, and periodically restore one to verify the procedure. AWS Backup for DynamoDB.
- Resource policies. Apply table-level explicit denies where an accidental grant would expose table updates or deletions. AWS resource policy authorization.
- Least privilege. Grant table administration only to the roles that need it. Scope application roles to the tables and data operations they actually use. AWS DynamoDB IAM guidance.
Recover after an accidental DynamoDB table deletion
Start by checking the source account and Region for the available recovery points. The options depend on what was enabled before the deletion.
| Recovery source | What you can restore and for how long |
|---|---|
| PITR was enabled when the table was deleted | At deletion, DynamoDB creates a SYSTEM backup named like Orders$DeletedTableBackup. It is retained for 35 days and restores the table as it stood just before deletion. The rolling PITR timeline is available while the original table exists. AWS PITR deletion behavior |
| DynamoDB on-demand backup | Restore a previously taken snapshot. DynamoDB retains these backups until you explicitly delete them. AWS DynamoDB backup features |
| AWS Backup recovery point | Restore a snapshot from its AWS Backup vault before it expires under the backup plan's retention rules. AWS Backup lifecycle and restores |
For a system backup, run aws dynamodb list-backups --table-name Orders --backup-type SYSTEM. Match the backup to the deleted table and the incident time, then restore it using aws dynamodb restore-table-from-backup with its --backup-arn and a --target-table-name. For an AWS Backup recovery point, start the restore in AWS Backup. ListBackups API, DynamoDB CLI restore procedure, AWS Backup restore procedure.
If the table still exists and the incident deleted items, use RestoreTableToPointInTime with a timestamp before the unwanted writes, within the available PITR window. If the whole table is gone and both PITR and existing backups were absent, there is no DynamoDB recovery point to restore. RestoreTableToPointInTime API, AWS PITR deletion behavior.
The restore creates a new physical table. Wait for it to become active, check the data, re-enable deletion protection and PITR, and reapply the applicable access policies, TTL, and stream settings before redirecting application traffic. See the DynamoDB backup and restore guide for the restore workflow and AWS restore settings for what to reconfigure.
Frequently Asked Questions
What does DynamoDB DeletionProtectionEnabled do?
How do I check whether deletion protection is enabled?
Can IAM allow enabling DynamoDB deletion protection while denying disabling it?
Will CloudFormation delete a protected DynamoDB table?
Can I recover a DynamoDB table after deleting it?
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
- SSH GUI Client
- Chat With Cloud
- MongoDB GUI Client
- AWS Cost Monitoring
- DynamoDB Query Builder
- DynamoDB Code Examples
- DynamoDB Node.js Queries
- DynamoDB JSON Converter
- DynamoDB UUID Generator
- DynamoDB Local Admin GUI
- DynamoDB Pricing Calculator
- DynamoDB Single-Table Design
- Best DynamoDB GUI Clients
- Dynobase vs DynoTable