{
    "componentChunkName": "component---src-templates-mdx-content-page-js",
    "path": "/dynamodb-deletion-protection/",
    "result": {"data":{"mdx":{"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"path\": \"/dynamodb-deletion-protection/\",\n  \"publishedDate\": \"2026-11-20\",\n  \"updatedDate\": \"2026-11-20\",\n  \"metaTitle\": \"DynamoDB Deletion Protection: Enable, Verify, Recover\",\n  \"metaDescription\": \"Prevent DynamoDB table deletion with the console, CLI, SDKs or IaC. Verify each replica, restrict who can turn protection off, and recover from a backup.\",\n  \"title\": \"DynamoDB Deletion Protection: How to Enable and Verify It\",\n  \"authorName\": \"Rafal Wilinski\",\n  \"authorLink\": \"https://x.com/rafalwilinski\",\n  \"authorImage\": \"/images/authors/rafal-wilinski.jpg\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"To prevent accidental DynamoDB table deletion, set \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DeletionProtectionEnabled\"), \" to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"true\"), \" when you create or update the table. DynamoDB then rejects \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"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. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html#WorkingWithTables.Basics.DeletionProtection\"\n  }, \"AWS deletion protection guide\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables-bestpractices.html#globaltables-bestpractices-deletionprotection\"\n  }, \"AWS global table guidance\"), \".\"), mdx(\"h2\", null, \"What DynamoDB deletion protection covers\"), mdx(\"p\", null, \"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 \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"UpdateTable\"), \", then a principal with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"dynamodb:DeleteTable\"), \" can \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/delete-dynamodb-table/\"\n  }, \"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 \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/dynamodb-errors/kms-key-access-denied-error-dynamodb/\"\n  }, \"loses access to its customer managed encryption key\"), \". \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html\"\n  }, \"AWS table operations\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTable.html\"\n  }, \"UpdateTable API\"), \".\"), mdx(\"p\", null, \"Your application can still use \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"DeleteItem\")), \" or send delete requests in \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"BatchWriteItem\")), \" if its role is allowed to do so. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html\"\n  }, \"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.\"), mdx(\"h3\", null, \"Does it protect global table replicas?\"), mdx(\"p\", null, \"Yes. Deletion protection belongs to the individual replica, and DynamoDB configures it independently even for \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/dynamodb-global-tables/\"\n  }, \"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 \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DeletionProtectionEnabled: true\"), \" on each entry in \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Replicas\"), \". \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/V2globaltables_HowItWorks.html#V2globaltables_HowItWorks.setting-synchronization\"\n  }, \"Same-account settings\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/V2globaltables_MA_HowItWorks.html\"\n  }, \"multi-account settings\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-dynamodb-globaltable-replicaspecification.html\"\n  }, \"CloudFormation replica properties\"), \".\"), mdx(\"h2\", null, \"Enable and check DynamoDB deletion protection\"), mdx(\"p\", null, \"Select the intended AWS account and Region before running the examples. The CLI, SDK, and Terraform examples use an on-demand table named \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Orders\"), \" with a string partition key called \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"orderId\"), \".\"), mdx(\"h3\", null, \"AWS Management Console\"), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"New table.\"), \" In DynamoDB, choose \", mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Tables \\u2192 Create table\"), \", enter the table details, choose \", mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Customize settings\"), \", and turn on \", mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Deletion protection\"), \" before creating it. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://aws.amazon.com/blogs/database/how-to-use-deletion-protection-to-enhance-your-amazon-dynamodb-table-protection-strategy/\"\n  }, \"AWS console walkthrough\"), \".\"), mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Existing table.\"), \" Open the table, choose \", mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Additional settings\"), \", and enable protection in the \", mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Deletion protection\"), \" panel. Check the same panel after saving. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html\"\n  }, \"AWS DynamoDB Developer Guide\"), \".\")), mdx(\"h3\", null, \"AWS CLI v2\"), mdx(\"p\", null, \"Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--deletion-protection-enabled\"), \" with \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/cli/latest/reference/dynamodb/create-table.html\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"create-table\")), \" to protect a new table.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-bash\"\n  }, \"aws dynamodb create-table --table-name Orders \\\\\\n  --attribute-definitions AttributeName=orderId,AttributeType=S \\\\\\n  --key-schema AttributeName=orderId,KeyType=HASH \\\\\\n  --billing-mode PAY_PER_REQUEST \\\\\\n  --deletion-protection-enabled\\n\")), mdx(\"p\", null, \"For an existing table, use \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/cli/latest/reference/dynamodb/update-table.html\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"update-table\")), \".\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-bash\"\n  }, \"aws dynamodb update-table --table-name Orders --deletion-protection-enabled\\n\")), mdx(\"p\", null, \"Wait for the table to become \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ACTIVE\"), \", then check the live value. The expected output is \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"true\"), \". For a global table, repeat the check with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--region\"), \" set to each replica's Region. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/cli/latest/reference/dynamodb/wait/table-exists.html\"\n  }, \"AWS CLI waiter\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TableDescription.html\"\n  }, \"DescribeTable result fields\"), \".\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-bash\"\n  }, \"aws dynamodb wait table-exists --table-name Orders\\naws dynamodb describe-table --table-name Orders \\\\\\n  --query 'Table.DeletionProtectionEnabled' --output json\\n\")), mdx(\"h3\", null, \"AWS SDK for JavaScript v3\"), mdx(\"p\", null, \"Use the low-level \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"@aws-sdk/client-dynamodb\"), \" client. Run one of \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/CreateTableCommand/\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"CreateTableCommand\")), \" or \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/UpdateTableCommand/\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"UpdateTableCommand\")), \", then check with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DescribeTable\"), \" after the table is active.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-js\"\n  }, \"import {\\n  CreateTableCommand,\\n  DescribeTableCommand,\\n  DynamoDBClient,\\n  UpdateTableCommand,\\n  waitUntilTableExists,\\n} from \\\"@aws-sdk/client-dynamodb\\\"\\n\\nconst client = new DynamoDBClient({})\\nconst protection = { TableName: \\\"Orders\\\", DeletionProtectionEnabled: true }\\n\\nif (process.argv.includes(\\\"--create\\\")) {\\n  await client.send(new CreateTableCommand({\\n    ...protection,\\n    AttributeDefinitions: [{ AttributeName: \\\"orderId\\\", AttributeType: \\\"S\\\" }],\\n    KeySchema: [{ AttributeName: \\\"orderId\\\", KeyType: \\\"HASH\\\" }],\\n    BillingMode: \\\"PAY_PER_REQUEST\\\",\\n  }))\\n} else {\\n  await client.send(new UpdateTableCommand(protection))\\n}\\n\\nawait waitUntilTableExists({ client, maxWaitTime: 300 }, { TableName: \\\"Orders\\\" })\\nconst { Table } = await client.send(new DescribeTableCommand({ TableName: \\\"Orders\\\" }))\\nconsole.log(Table?.DeletionProtectionEnabled)\\n\")), mdx(\"p\", null, \"Save it as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"protect-orders.mjs\"), \". Run \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"node protect-orders.mjs --create\"), \" for a new table or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"node protect-orders.mjs\"), \" for an existing one. See the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/programming-with-javascript.html#programming-with-javascript-waiters\"\n  }, \"AWS SDK waiter example\"), \".\"), mdx(\"h3\", null, \"Python with boto3\"), mdx(\"p\", null, \"Pass \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DeletionProtectionEnabled=True\"), \" to \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/boto3/latest/reference/services/dynamodb/client/create_table.html\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"create_table\")), \" or \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/boto3/latest/reference/services/dynamodb/client/update_table.html\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"update_table\")), \". Save as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"protect_orders.py\"), \" and use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--create\"), \" only for a new table.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-python\"\n  }, \"import sys\\n\\nimport boto3\\n\\nddb = boto3.client(\\\"dynamodb\\\")\\nprotection = {\\\"TableName\\\": \\\"Orders\\\", \\\"DeletionProtectionEnabled\\\": True}\\n\\nif \\\"--create\\\" in sys.argv[1:]:\\n    ddb.create_table(\\n        **protection,\\n        AttributeDefinitions=[{\\\"AttributeName\\\": \\\"orderId\\\", \\\"AttributeType\\\": \\\"S\\\"}],\\n        KeySchema=[{\\\"AttributeName\\\": \\\"orderId\\\", \\\"KeyType\\\": \\\"HASH\\\"}],\\n        BillingMode=\\\"PAY_PER_REQUEST\\\",\\n    )\\nelse:\\n    ddb.update_table(**protection)\\n\\nddb.get_waiter(\\\"table_exists\\\").wait(TableName=\\\"Orders\\\")\\nprint(ddb.describe_table(TableName=\\\"Orders\\\")[\\\"Table\\\"][\\\"DeletionProtectionEnabled\\\"])\\n\")), mdx(\"h3\", null, \"CloudFormation\"), mdx(\"p\", null, \"Set \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DeletionProtectionEnabled\"), \" under \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Properties\"), \" on \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"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 \", mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"No interruption\"), \". The two retention attributes in this example are separate safeguards, explained below. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-dynamodb-table.html\"\n  }, \"AWS table resource reference\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/dynamodb-cloudformation/\"\n  }, \"DynamoDB CloudFormation examples\"), \".\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-yaml\"\n  }, \"Resources:\\n  OrdersTable:\\n    Type: AWS::DynamoDB::Table\\n    DeletionPolicy: Retain\\n    UpdateReplacePolicy: Retain\\n    Properties:\\n      BillingMode: PAY_PER_REQUEST\\n      AttributeDefinitions:\\n        - AttributeName: orderId\\n          AttributeType: S\\n      KeySchema:\\n        - AttributeName: orderId\\n          KeyType: HASH\\n      DeletionProtectionEnabled: true\\n\")), mdx(\"h3\", null, \"AWS CDK v2\"), mdx(\"p\", null, \"Set \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"deletionProtection: true\"), \" on \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Table\"), \" when you define it. For an existing CDK-managed table, change the property on the same construct and deploy the existing stack. For \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"TableV2\"), \" global tables, configure \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"deletionProtection\"), \" for the primary and in each replica's settings. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.TableProps.html\"\n  }, \"CDK TableProps\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb-readme.html\"\n  }, \"CDK DynamoDB construct reference\"), \".\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-ts\"\n  }, \"import { App, RemovalPolicy, Stack } from \\\"aws-cdk-lib\\\"\\nimport { AttributeType, BillingMode, Table } from \\\"aws-cdk-lib/aws-dynamodb\\\"\\n\\nconst app = new App()\\nconst stack = new Stack(app, \\\"OrdersStack\\\")\\n\\nnew Table(stack, \\\"OrdersTable\\\", {\\n  partitionKey: { name: \\\"orderId\\\", type: AttributeType.STRING },\\n  billingMode: BillingMode.PAY_PER_REQUEST,\\n  deletionProtection: true,\\n  removalPolicy: RemovalPolicy.RETAIN,\\n})\\n\")), mdx(\"h3\", null, \"Terraform\"), mdx(\"p\", null, \"Set \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"deletion_protection_enabled = true\"), \" on \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"aws_dynamodb_table\"), \". For an existing table already in Terraform state, add it to that resource, check that \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"terraform plan\"), \" shows an in-place update, and apply. The AWS provider sends the flag in \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"UpdateTable\"), \" when this argument changes. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table\"\n  }, \"HashiCorp AWS provider reference\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://github.com/hashicorp/terraform-provider-aws/blob/main/internal/service/dynamodb/table.go\"\n  }, \"provider update implementation\"), \".\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-hcl\"\n  }, \"resource \\\"aws_dynamodb_table\\\" \\\"orders\\\" {\\n  name                        = \\\"Orders\\\"\\n  billing_mode                = \\\"PAY_PER_REQUEST\\\"\\n  hash_key                    = \\\"orderId\\\"\\n  deletion_protection_enabled = true\\n\\n  attribute {\\n    name = \\\"orderId\\\"\\n    type = \\\"S\\\"\\n  }\\n}\\n\")), mdx(\"h2\", null, \"Restrict who can turn deletion protection off\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DeletionProtectionEnabled\"), \" is an API field. The \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/service-authorization/latest/reference/list_dynamodb.html\"\n  }, \"DynamoDB IAM authorization reference\"), \" lists no condition key that lets IAM distinguish \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"true\"), \" from \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"false\"), \" on \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"dynamodb:UpdateTable\"), \". The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"aws:ResourceTag\"), \" condition can scope a rule to selected tables. The rule still governs the whole action, including changes to throughput, indexes, and streams. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://aws.amazon.com/blogs/database/use-guardrails-to-protect-dynamodb-tables/\"\n  }, \"AWS guidance on table guardrails\"), \".\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Give application roles only the item operations they need. Reserve \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"dynamodb:UpdateTable\"), \" for a controlled maintenance or deployment role scoped to the required table ARNs. Give \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"dynamodb:DeleteTable\"), \" only 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. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"/dynamodb-access-control/\"\n  }, \"DynamoDB access control\"), \", \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-servicerole.html\"\n  }, \"CloudFormation service roles\"), \".\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"For an explicit guardrail across a member account, use an AWS Organizations service control policy (SCP). For example, deny \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"dynamodb:UpdateTable\"), \" on the production table ARN unless \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"aws:PrincipalArn\"), \" matches your approved maintenance role's IAM ARN. Add an independently scoped deny for \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"dynamodb:DeleteTable\"), \" if 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. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html\"\n  }, \"SCP scope\"), \", \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-principalarn\"\n  }, \"IAM principal ARN condition\"), \".\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"A DynamoDB table resource policy can add an explicit deny on \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"UpdateTable\"), \" or \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"DeleteTable\"), \" for 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. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/rbac-iam-actions.html\"\n  }, \"Supported resource-policy actions\"), \", \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables-security.html\"\n  }, \"AWS global tables IAM guidance\"), \".\")), mdx(\"h3\", null, \"Verify the setting and the permission separately\"), mdx(\"p\", null, \"On a disposable table covered by the same rules, try \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"update-table --no-deletion-protection-enabled\"), \" as the application role. Expect an access-denied response and confirm that \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DescribeTable\"), \" still shows \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"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 \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/dynamodb-logging/\"\n  }, \"CloudTrail management events\"), \" for \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"UpdateTable\"), \", including the caller and request parameters. Audit the live setting at scale with Security Hub control \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DynamoDB.6\"), \" or the AWS Config rule \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"dynamodb-table-deletion-protection-enabled\"), \". \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_testing-policies.html\"\n  }, \"IAM policy simulator\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/understanding-ddb-log-entries.html\"\n  }, \"DynamoDB CloudTrail events\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/securityhub/latest/userguide/dynamodb-controls.html#dynamodb-6\"\n  }, \"Security Hub controls\"), \".\"), mdx(\"h2\", null, \"CloudFormation and CDK stack deletion\"), mdx(\"table\", null, mdx(\"thead\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"thead\"\n  }, mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Setting\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Effect\"))), mdx(\"tbody\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"DeletionProtectionEnabled: true\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"DynamoDB rejects a delete request from any caller, including CloudFormation. \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-dynamodb-table.html\"\n  }, \"AWS table resource reference\"))), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"DeletionPolicy: Retain\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"CloudFormation keeps the physical table when you delete the stack or remove the resource from the template. \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-attribute-deletionpolicy.html\"\n  }, \"DeletionPolicy\"))), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"UpdateReplacePolicy: Retain\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"CloudFormation keeps the old physical table if a stack update replaces it. \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-attribute-updatereplacepolicy.html\"\n  }, \"UpdateReplacePolicy\"))), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"CDK \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"RemovalPolicy.RETAIN\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"For the \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"Table\"), \" above, CDK synthesizes both retention attributes. Check them with \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"cdk synth\"), \". \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://docs.aws.amazon.com/cdk/v2/guide/resources.html\"\n  }, \"CDK resource policies\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/lib/cfn-resource.ts\"\n  }, \"CDK implementation\"))))), mdx(\"p\", null, \"If CloudFormation tries to delete a protected table, DynamoDB rejects the request and the stack can reach \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DELETE_FAILED\"), \". Other resources may already have been deleted. To finish the stack deletion and keep the table, choose \", mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"Retry delete \\u2192 Delete this stack but retain resources\"), \" and select the table, or retry with the table's logical ID in \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"RetainResources\"), \". If the table itself is meant to be deleted, \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/dynamodb-faq/how-to-forcefully-delete-a-dynamodb-table/\"\n  }, \"disable protection as an authorized role\"), \" before retrying. For planned stack teardown that should preserve data, declare \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Retain\"), \" while the stack is still healthy. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-delete-stack.html\"\n  }, \"AWS stack deletion procedure\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html#troubleshooting-errors-delete-stack-fails\"\n  }, \"CloudFormation troubleshooting\"), \".\"), mdx(\"h2\", null, \"What error do you see when deleting a protected table?\"), mdx(\"p\", null, \"AWS documents this CLI response to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"aws dynamodb delete-table --table-name Orders\"), \" when the caller has delete permission and protection is enabled. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://repost.aws/knowledge-center/dynamodb-accidental-delete-protection\"\n  }, \"AWS re:Post Knowledge Center\"), \".\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-text\"\n  }, \"An error occurred (ValidationException) when calling the DeleteTable operation: Resource cannot be deleted as it is currently protected against deletion. Disable deletion protection first.\\n\")), mdx(\"p\", null, \"Confirm the protection flag with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DescribeTable\"), \". If you see an \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/dynamodb-errors/is-not-authorized-to-perform-dynamodb-on-resource/\"\n  }, \"access-denied error\"), \", check the caller's effective IAM permissions, the resource policy, and any applicable SCP. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html\"\n  }, \"AWS IAM evaluation logic\"), \".\"), mdx(\"h2\", null, \"Layered protection checklist\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Deletion protection.\"), \" Enable it in infrastructure code on production tables and verify the live value in every replica Region. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables-bestpractices.html\"\n  }, \"AWS global table guidance\"), \".\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"PITR.\"), \" Turn on \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"/dynamodb-point-in-time-recovery/\"\n  }, \"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. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Point-in-time-recovery.html\"\n  }, \"AWS PITR reference\"), \".\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"AWS Backup.\"), \" Schedule backups with a retention period that meets your recovery requirements, and periodically restore one to verify the procedure. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/backuprestore_HowItWorksAWS.html\"\n  }, \"AWS Backup for DynamoDB\"), \".\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Resource policies.\"), \" Apply table-level explicit denies where an accidental grant would expose table updates or deletions. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/rbac-auth-iam-id-based-policies-DDB.html\"\n  }, \"AWS resource policy authorization\"), \".\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Least privilege.\"), \" Grant table administration only to the roles that need it. Scope application roles to the tables and data operations they actually use. \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/security_iam_service-with-iam.html\"\n  }, \"AWS DynamoDB IAM guidance\"), \".\")), mdx(\"h2\", null, \"Recover after an accidental DynamoDB table deletion\"), mdx(\"p\", null, \"Start by checking the source account and Region for the available recovery points. The options depend on what was enabled before the deletion.\"), mdx(\"table\", null, mdx(\"thead\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"thead\"\n  }, mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Recovery source\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"What you can restore and for how long\"))), mdx(\"tbody\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"PITR was enabled when the table was deleted\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"At deletion, DynamoDB creates a \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"SYSTEM\"), \" backup named like \", mdx(\"inlineCode\", {\n    parentName: \"td\"\n  }, \"Orders$DeletedTableBackup\"), \". It is retained for \", mdx(\"strong\", {\n    parentName: \"td\"\n  }, \"35 days\"), \" and restores the table as it stood just before deletion. The rolling PITR timeline is available while the original table exists. \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PointInTimeRecovery_Howitworks.html\"\n  }, \"AWS PITR deletion behavior\"))), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"DynamoDB on-demand backup\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Restore a previously taken snapshot. DynamoDB retains these backups until you explicitly delete them. \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://aws.amazon.com/dynamodb/features/\"\n  }, \"AWS DynamoDB backup features\"))), mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"AWS Backup recovery point\"), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Restore a snapshot from its AWS Backup vault before it expires under the backup plan's retention rules. \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStartedBackupsAWS.html\"\n  }, \"AWS Backup lifecycle and restores\"))))), mdx(\"p\", null, \"For a system backup, run \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"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 \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"aws dynamodb restore-table-from-backup\"), \" with its \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--backup-arn\"), \" and a \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--target-table-name\"), \". For an AWS Backup recovery point, start the restore in AWS Backup. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListBackups.html\"\n  }, \"ListBackups API\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Restore.Tutorial.html\"\n  }, \"DynamoDB CLI restore procedure\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/aws-backup/latest/devguide/restoring-dynamodb.html\"\n  }, \"AWS Backup restore procedure\"), \".\"), mdx(\"p\", null, \"If the table still exists and the incident deleted items, use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"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. \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_RestoreTableToPointInTime.html\"\n  }, \"RestoreTableToPointInTime API\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PointInTimeRecovery_Howitworks.html\"\n  }, \"AWS PITR deletion behavior\"), \".\"), mdx(\"p\", null, \"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 \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/dynamodb-backup-and-restore/\"\n  }, \"DynamoDB backup and restore guide\"), \" for the restore workflow and \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/pointintimerecovery_restores.html\"\n  }, \"AWS restore settings\"), \" for what to reconfigure.\"), mdx(FAQ, {\n    questions: [{\n      question: \"What does DynamoDB DeletionProtectionEnabled do?\",\n      answer: \"When true, it blocks DeleteTable until an authorized caller turns protection off. Item deletion and TTL expiration can still occur.\"\n    }, {\n      question: \"How do I check whether deletion protection is enabled?\",\n      answer: \"Read Table.DeletionProtectionEnabled in DescribeTable or check the Deletion protection panel in the DynamoDB console. For a global table, check each replica in its own Region.\"\n    }, {\n      question: \"Can IAM allow enabling DynamoDB deletion protection while denying disabling it?\",\n      answer: \"DynamoDB exposes no IAM condition key for the flag. Restrict UpdateTable on the relevant table to approved roles. That restriction applies to other changes made through UpdateTable as well.\"\n    }, {\n      question: \"Will CloudFormation delete a protected DynamoDB table?\",\n      answer: \"DynamoDB rejects the delete and the stack can reach DELETE_FAILED. A Retain deletion policy tells CloudFormation to keep the table when the stack is deleted.\"\n    }, {\n      question: \"Can I recover a DynamoDB table after deleting it?\",\n      answer: \"If PITR was enabled at deletion, DynamoDB keeps a snapshot of the table just before deletion for 35 days. You can also restore an available DynamoDB on-demand backup or AWS Backup recovery point.\"\n    }],\n    mdxType: \"FAQ\"\n  }));\n}\n;\nMDXContent.isMDXComponent = true;","frontmatter":{"publishedDate":"2026-11-20","updatedDate":"2026-11-20","path":"/dynamodb-deletion-protection/","metaTitle":"DynamoDB Deletion Protection: Enable, Verify, Recover","metaDescription":"Prevent DynamoDB table deletion with the console, CLI, SDKs or IaC. Verify each replica, restrict who can turn protection off, and recover from a backup.","title":"DynamoDB Deletion Protection: How to Enable and Verify It","authorName":"Rafal Wilinski","authorLink":"https://x.com/rafalwilinski","authorImage":"/images/authors/rafal-wilinski.jpg","image":null}}},"pageContext":{}},
    "staticQueryHashes": ["3649515864"]}