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
fix(s3): DeletePublicAccessBlock now actually removes the config (404 on get) (#921)
Yuriy R3acce176edac
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 461719b2..a148334d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).- **CloudFormation — `GetTemplateSummary` now returns `Capabilities` and `CapabilitiesReason`** — the handler already accepted `TemplateBody` and returned `Parameters` / `ResourceTypes` correctly, but omitted the `Capabilities` and `CapabilitiesReason` fields. These are now computed from the template: `CAPABILITY_NAMED_IAM` for IAM resources with explicit name properties (`RoleName`, `UserName`, etc.), `CAPABILITY_IAM` for unnamed IAM resources, and `CAPABILITY_AUTO_EXPAND` for templates with a `Transform`. `CapabilitiesReason` uses the format confirmed against the AWS API: `"The following resource(s) require capabilities: [<type>]"`. Contributed by @maximoosemine.- **Lambda - CreateEventSourceMapping persists FilterCriteria** — CreateEventSourceMapping was silently dropping the FilterCriteria parameter, so any filter specified at creation time was never applied.- **ECS — `RunTask` now applies `containerOverrides.command` to the launched Docker container** — Overridden commands (including an explicit empty command) were ignored at runtime because the Docker `containers.run(...)` call still used the task-definition command. The effective container definition now carries the matched override command into Docker, while non-overridden containers keep their defaults.+- **S3 — `DeletePublicAccessBlock` now actually clears the configuration** — after delete, `GetPublicAccessBlock` returned a default all-blocked configuration with HTTP 200 instead of `NoSuchPublicAccessBlockConfiguration` (404), so the delete was not observable and Terraform's `aws_s3_bucket_public_access_block` delete waiter timed out (`found resource`), blocking `terraform destroy`. `GetPublicAccessBlock` now returns 404 when no configuration is set (never configured, or deleted). Reported by @kamegoro.- **Lambda - CloudFormation-created ESMs now poll DynamoDB Streams** — Before, these streams were not getting polled.---diff --git a/ministack/services/s3.py b/ministack/services/s3.pyindex c6ea263c..10f81ef9 100644--- a/ministack/services/s3.py+++ b/ministack/services/s3.py@@ -1420,13 +1420,15 @@ def _get_public_access_block(name: str):stored = _buckets[name].get("_public_access_block")if stored:return 200, {"Content-Type": "application/xml"}, stored- # Default: all public access blocked- root = Element("PublicAccessBlockConfiguration", xmlns=S3_NS)- SubElement(root, "BlockPublicAcls").text = "true"- SubElement(root, "IgnorePublicAcls").text = "true"- SubElement(root, "BlockPublicPolicy").text = "true"- SubElement(root, "RestrictPublicBuckets").text = "true"- return 200, {"Content-Type": "application/xml"}, _xml_body(root)+ # No configuration set (never put, or deleted): real S3 returns 404 rather+ # than a default block, so DeletePublicAccessBlock is observable and the+ # Terraform delete waiter can complete.+ return _error(+ "NoSuchPublicAccessBlockConfiguration",+ "The public access block configuration was not found",+ 404,+ f"/{name}",+ )def _delete_public_access_block(name: str):diff --git a/tests/test_s3.py b/tests/test_s3.pyindex f03e744b..eb439e91 100644--- a/tests/test_s3.py+++ b/tests/test_s3.py@@ -882,6 +882,11 @@ def test_s3_public_access_block(s3):assert cfg["BlockPublicAcls"] is Trueassert cfg["BlockPublicPolicy"] is Falses3.delete_public_access_block(Bucket=bkt)+ # After delete the config is gone: GetPublicAccessBlock must 404 instead of+ # returning a default block (otherwise Terraform's delete waiter times out).+ with pytest.raises(ClientError) as exc:+ s3.get_public_access_block(Bucket=bkt)+ assert exc.value.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration"def test_s3_ownership_controls(s3):bkt = "intg-s3-ownership"