carlos / platform Public

region-host: the store policy's overlap Deny spares s3:DeleteObject

The Deny that keeps a careless store prefix off the deployment's own buckets also denied s3:DeleteObject there. That is how a box releases an instance's lease, and how litestream retention, the registry snapshot prune, logship and the metrics flush work. It stranded every lease on flagship on 2026-09-09 (hand-fixed then, never fixed in the module) and on dev on 2026-10-29, when dev's store prefix was set (hand-fixed with Paul's approval). The Deny keeps DeleteBucket and CreateBucket. New plan-time test store_deny_spares_object_deletes (fails on the old Deny, passes now).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 3f12371336b29b846a98827330b467bb14a62a9d parent d13365f
2 files changed, +30 −1
  • infra/modules/region-host/main.tf +9 −1
  • infra/modules/region-host/tests/store_scanning.tftest.hcl +21 −0

CI failed — run details

diff --git a/infra/modules/region-host/main.tf b/infra/modules/region-host/main.tf
index aca89632e..0e206d0ea 100644
--- a/infra/modules/region-host/main.tf
+++ b/infra/modules/region-host/main.tf
@@ -718,9 +718,17 @@ resource "aws_iam_role_policy" "host_store" {
# — would otherwise hand the box DeleteBucket on the control plane it
# runs from. An explicit Deny beats every Allow in IAM, so this holds
# whatever prefix an operator chooses, including a careless one.
+ #
+ # Bucket-level actions only. s3:DeleteObject must NOT be here: the box
+ # deletes objects in its own deployment bucket all the time (releasing an
+ # instance's lease is a DeleteObject on instances/<host>/lock.json, and
+ # so are litestream retention, the registry snapshot prune, logship and
+ # the metrics flush). Denying it stranded every lease on flagship on
+ # 2026-09-09 and on dev on 2026-10-29. Object deletes in the deployment
+ # buckets are already granted, and bounded, by the buckets policy.
{
Effect = "Deny"
- Action = ["s3:DeleteBucket", "s3:DeleteObject", "s3:CreateBucket"]
+ Action = ["s3:DeleteBucket", "s3:CreateBucket"]
Resource = [
var.deployment_bucket_arn,
"${var.deployment_bucket_arn}/*",
diff --git a/infra/modules/region-host/tests/store_scanning.tftest.hcl b/infra/modules/region-host/tests/store_scanning.tftest.hcl
index 3ec400b4f..6413b0ed8 100644
--- a/infra/modules/region-host/tests/store_scanning.tftest.hcl
+++ b/infra/modules/region-host/tests/store_scanning.tftest.hcl
@@ -68,3 +68,24 @@ run "refused_without_a_store_prefix" {
}
expect_failures = [aws_iam_role_policy.host_store_scan]
}
+
+# The store policy's overlap Deny names bucket-level actions only. A Deny on
+# s3:DeleteObject over the deployment buckets broke every lease release
+# (flagship 2026-09-09, dev 2026-10-29).
+run "store_deny_spares_object_deletes" {
+ command = plan
+ assert {
+ condition = alltrue([
+ for st in jsondecode(aws_iam_role_policy.host_store[0].policy).Statement :
+ !contains(flatten([st.Action]), "s3:DeleteObject") if st.Effect == "Deny"
+ ])
+ error_message = "the store policy must never Deny s3:DeleteObject: lease releases delete objects in the deployment bucket"
+ }
+ assert {
+ condition = anytrue([
+ for st in jsondecode(aws_iam_role_policy.host_store[0].policy).Statement :
+ st.Effect == "Deny" && contains(flatten([st.Action]), "s3:DeleteBucket")
+ ])
+ error_message = "the overlap Deny on DeleteBucket stays"
+ }
+}