feat(dynamodb): implement deletion_protection_enabled#380
Merged
vieiralucas merged 2 commits intomainfrom Apr 14, 2026
Merged
Conversation
There was a problem hiding this comment.
1 issue found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/fakecloud-cloudformation/src/resource_provisioner.rs">
<violation number="1" location="crates/fakecloud-cloudformation/src/resource_provisioner.rs:696">
P2: CloudFormation table creation ignores the `DeletionProtectionEnabled` property by hardcoding `deletion_protection_enabled` to `false`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Real AWS DynamoDB lets you mark a table as deletion-protected via CreateTable and UpdateTable, and rejects DeleteTable while the flag is set with ResourceInUseException. fakecloud was ignoring the attribute entirely — DescribeTable returned nothing, so Terraform's `aws_dynamodb_table` provider saw drift on every refresh, and the upstream `TestAccDynamoDBTable_deletion_protection` test failed. - DynamoTable state struct gains `deletion_protection_enabled` - CreateTable parses `DeletionProtectionEnabled` from the request - UpdateTable can toggle it - DescribeTable always returns it - DeleteTable refuses with ResourceInUseException while it's enabled New e2e test dynamodb_deletion_protection_blocks_delete_table covers the full lifecycle: create-protected → describe → delete (denied) → update-clear → delete (allowed). Removes `TestAccDynamoDBTable_deletion_protection` from the tfacc deny-list. First entry to be driven from the deny-list to zero.
769e7a7 to
0207bb0
Compare
…::Table Cubic flagged that the CFN provisioner was hardcoding deletion_protection_enabled=false when creating a DynamoDB table, ignoring the property if the template specified it. Now reads the property from the resource's CloudFormation properties (accepting both bool and string-typed values, since CFN templates often use strings).
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/fakecloud-cloudformation/src/resource_provisioner.rs">
<violation number="1" location="crates/fakecloud-cloudformation/src/resource_provisioner.rs:700">
P1: `DeletionProtectionEnabled` is persisted on create but not enforced on delete in this provisioner, so protected tables can still be deleted via the CloudFormation path.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| stream_records: Arc::new(RwLock::new(Vec::new())), | ||
| sse_type: None, | ||
| sse_kms_key_arn: None, | ||
| deletion_protection_enabled, |
There was a problem hiding this comment.
P1: DeletionProtectionEnabled is persisted on create but not enforced on delete in this provisioner, so protected tables can still be deleted via the CloudFormation path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-cloudformation/src/resource_provisioner.rs, line 700:
<comment>`DeletionProtectionEnabled` is persisted on create but not enforced on delete in this provisioner, so protected tables can still be deleted via the CloudFormation path.</comment>
<file context>
@@ -692,8 +697,7 @@ impl ResourceProvisioner {
sse_kms_key_arn: None,
-
- deletion_protection_enabled: false,
+ deletion_protection_enabled,
};
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Batch 11 — first batch driving the DynamoDB tfacc deny-list down. Implements `deletion_protection_enabled`.
Real AWS DynamoDB lets you mark a table as deletion-protected via `CreateTable` and `UpdateTable`, and rejects `DeleteTable` while the flag is set with `ResourceInUseException`. fakecloud was ignoring the attribute entirely — DescribeTable returned nothing, so Terraform's `aws_dynamodb_table` provider saw drift on every refresh and the upstream `TestAccDynamoDBTable_deletion_protection` test failed.
Removes `TestAccDynamoDBTable_deletion_protection` from the tfacc deny-list. First entry to be driven from the deny-list to zero — the harness is now closing its own gaps.
Test plan
Summary by cubic
Add DynamoDB table deletion protection and enforce it on delete to match AWS behavior.
DescribeTablenow returns the flag to prevent Terraform drift; CloudFormation now honorsDeletionProtectionEnabled.New Features
DeletionProtectionEnabledonCreateTable,UpdateTable, andDescribeTable.DeleteTablewithResourceInUseExceptionwhen protection is enabled.deletion_protection_enabledinDynamoTable(default false); add an e2e lifecycle test and enableTestAccDynamoDBTable_deletion_protectionintfacc.Bug Fixes
KeySchemaonCreateTableand returnValidationException.DeletionProtectionEnabledforAWS::DynamoDB::Table(accepts bool or string) instead of defaulting to false.Written for commit 17e2e43. Summary will update on new commits.