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>
infra/modules/region-host/main.tf+9 −1infra/modules/region-host/tests/store_scanning.tftest.hcl+21 −0
CI failed — run details
Intent
I would go with subagents, but I only have half my usage available, so I'm concerned I'll run out of tokens. Can kick this off in 90 minutes when my session rolls over.
Attributed to this commit: 56.4 g CO₂e (7,105,240 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-host-store-deny, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
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" |
| + } |
| +} |