Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
validate protection in DDB (#429)
Nahuel Nucera378f636d9ed0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4d123f1a..a3644a90 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,14 @@ Versioning follows [Semantic Versioning](https://semver.org/).---+## [1.3.10] — 2026-04-23++### Fixed+- **DynamoDB `DeletionProtectionEnabled` silently ignored on `CreateTable` / `UpdateTable`** — the table description never surfaced the field, and `DeleteTable` always succeeded regardless. Terraform's `aws_dynamodb_table` treats deletion protection as a safety-critical drift detector, so tables created with `deletion_protection_enabled = true` appeared unprotected and could be destroyed by a `terraform destroy` that real AWS would have refused. `CreateTable` now stores the flag (defaulting to `False`), `UpdateTable` toggles it, `DescribeTable` returns the current value, and `DeleteTable` refuses with `ValidationException: Table can't be deleted as deletion protection is enabled` when it's on — matching AWS behaviour exactly.+- **S3 `ListBuckets` missing `BucketArn` and `BucketRegion`** — the response contained only `Name` and `CreationDate`, so SDKs/tooling that consumed the newer fields (added by AWS in 2024) received `None` and either errored or silently skipped buckets. `ListBuckets` now emits both fields per bucket (`BucketArn` as `arn:aws:s3:::<name>`, `BucketRegion` from the bucket's stored region or `MINISTACK_REGION`). Reported by @mcdoit.++---+## [1.3.9] — 2026-04-22### Fixeddiff --git a/ministack/services/dynamodb.py b/ministack/services/dynamodb.pyindex 6eb51472..779b09bd 100644--- a/ministack/services/dynamodb.py+++ b/ministack/services/dynamodb.py@@ -313,6 +313,7 @@ def _create_table(data):"BillingModeSummary": {"BillingMode": data.get("BillingMode", "PROVISIONED")},"StreamSpecification": data.get("StreamSpecification"),"SSEDescription": _sse_description_from_spec(data.get("SSESpecification")),+ "DeletionProtectionEnabled": data.get("DeletionProtectionEnabled", False),}if data.get("StreamSpecification"):stream_label = now_iso()@@ -327,6 +328,9 @@ def _delete_table(data):name = data.get("TableName")if name not in _tables:return error_response_json("ResourceNotFoundException", f"Requested resource not found: Table: {name} not found", 400)+ if _tables[name].get("DeletionProtectionEnabled"):+ return error_response_json("ValidationException",+ "Table can't be deleted as deletion protection is enabled", 400)desc = _table_description(name)desc["TableStatus"] = "DELETING"del _tables[name]@@ -378,6 +382,8 @@ def _update_table(data):# response-shape SSEDescription with a proper Status field so the# Terraform waiter can observe ENABLED/DISABLED and return.table["SSEDescription"] = _sse_description_from_spec(data["SSESpecification"])+ if "DeletionProtectionEnabled" in data:+ table["DeletionProtectionEnabled"] = data["DeletionProtectionEnabled"]for update in data.get("GlobalSecondaryIndexUpdates", []):if "Create" in update:@@ -433,6 +439,7 @@ def _table_description(name):desc["LatestStreamArn"] = t.get("LatestStreamArn", "")if t.get("SSEDescription"):desc["SSEDescription"] = t["SSEDescription"]+ desc["DeletionProtectionEnabled"] = t.get("DeletionProtectionEnabled", False)desc["WarmThroughput"] = t.get("WarmThroughput", {"ReadUnitsPerSecond": 0,"WriteUnitsPerSecond": 0,diff --git a/pyproject.toml b/pyproject.tomlindex c4bab3cb..f61d2ce3 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"[project]name = "ministack"-version = "1.3.9"+version = "1.3.10"description = "Free, open-source local AWS emulator — drop-in LocalStack replacement"readme = "README.md"license = { file = "LICENSE" }diff --git a/tests/test_dynamodb.py b/tests/test_dynamodb.pyindex 1656dd46..7fc171a2 100644--- a/tests/test_dynamodb.py+++ b/tests/test_dynamodb.py@@ -355,6 +355,46 @@ def test_dynamodb_delete_table_not_found(ddb):ddb.delete_table(TableName="t_nonexistent_xyz")assert exc.value.response["Error"]["Code"] == "ResourceNotFoundException"++def test_dynamodb_deletion_protection(ddb):+ # AWS: DeletionProtectionEnabled=True blocks DeleteTable with ValidationException;+ # UpdateTable toggles the flag; DescribeTable reflects current state.+ ddb.create_table(+ TableName="t_protected",+ KeySchema=[{"AttributeName": "pk", "KeyType": "HASH"}],+ AttributeDefinitions=[{"AttributeName": "pk", "AttributeType": "S"}],+ BillingMode="PAY_PER_REQUEST",+ DeletionProtectionEnabled=True,+ )+ desc = ddb.describe_table(TableName="t_protected")["Table"]+ assert desc["DeletionProtectionEnabled"] is True++ with pytest.raises(ClientError) as exc:+ ddb.delete_table(TableName="t_protected")+ assert exc.value.response["Error"]["Code"] == "ValidationException"+ assert "deletion protection" in exc.value.response["Error"]["Message"].lower()++ ddb.update_table(TableName="t_protected", DeletionProtectionEnabled=False)+ desc = ddb.describe_table(TableName="t_protected")["Table"]+ assert desc["DeletionProtectionEnabled"] is False++ resp = ddb.delete_table(TableName="t_protected")+ assert resp["TableDescription"]["TableStatus"] == "DELETING"+ assert "t_protected" not in ddb.list_tables()["TableNames"]+++def test_dynamodb_deletion_protection_defaults_false(ddb):+ # A table created without the flag should describe as False and delete freely.+ ddb.create_table(+ TableName="t_unprotected",+ KeySchema=[{"AttributeName": "pk", "KeyType": "HASH"}],+ AttributeDefinitions=[{"AttributeName": "pk", "AttributeType": "S"}],+ BillingMode="PAY_PER_REQUEST",+ )+ desc = ddb.describe_table(TableName="t_unprotected")["Table"]+ assert desc["DeletionProtectionEnabled"] is False+ ddb.delete_table(TableName="t_unprotected")+def test_dynamodb_describe_table(ddb):ddb.create_table(TableName="t_describe_gsi",