carlos / platform Public

pdf-host: admit a standby console's group too (additional client groups)

New optional input additional_client_security_group_ids: each group is
admitted on TCP 3000 beside client_security_group_id, and a
precondition refuses a group outside the client VPC. The client group
still sets the VPC, so adding a group changes the ingress rule in place
and nothing is replaced. Lets a deployment admit its failover standby up
front instead of editing and applying during an incident (Bill's review
of Tito infra #61). Mock-provider tests for both new rules; census
overlay pdf-host-client-groups.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 7d6c4fff7263940d32d5c40a0b395b10a4c368f8 parent c48e91e
7 files changed, +114 −2
  • docs/superpowers/notes/census-proposal-pdf-host-client-groups.md +23 −0
  • infra/modules/pdf-host/README.md +14 −1
  • infra/modules/pdf-host/main.tf +13 −1
  • infra/modules/pdf-host/tests/pdf_host.tftest.hcl +43 −0
  • infra/modules/pdf-host/variables.tf +10 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-pdf-host-client-groups.tsv +10 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/notes/census-proposal-pdf-host-client-groups.md b/docs/superpowers/notes/census-proposal-pdf-host-client-groups.md
new file mode 100644
index 000000000..e6c5dbb18
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-pdf-host-client-groups.md
@@ -0,0 +1,23 @@
+# Census approval: pdf-host-client-groups
+
+Ruling `census-ruling-pdf-host-client-groups`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `infra/modules/pdf-host/main.tf` `external` | body | unchanged (1) | Adds data.aws_security_group.additional_client (for_each over additional_client_security_group_ids) and admits those groups on TCP 3000 beside the client group; a precondition refuses a group outside the client VPC. No new read by the root binary; the box, role and fence are unchanged. |
+| `infra/modules/pdf-host/tests/pdf_host.tftest.hcl` `external` | body | unchanged (1) | Mock-provider tests for the standby group admitted, a group in another VPC refused, and a malformed id refused. |
+| `infra/modules/pdf-host/variables.tf` `external` | body | unchanged (1) | New optional input additional_client_security_group_ids (list of sg ids, default empty, validated as sg-...). No new read. |
+
+Envelopes re-pinned: `infra/modules/pdf-host`, `infra/modules/pdf-host/tests`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `infra/modules/pdf-host/main.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module source defining the PDF engine box, security group and SSM-only role; never read by the CARLOS root binary or a box agent at runtime
+- `infra/modules/pdf-host/tests/pdf_host.tftest.hcl` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-design-pdf-service;basis=mock-provider tests cover loopback names, mapped IPv6 and userinfo, case-insensitive HTTP, public hostname boundaries and the case-sensitive file exemption; retain private engine-port, metadata/fence retry and Docker memory checks; no live infrastructure calls; never read by the CARLOS root binary or a box agent at runtime
+- `infra/modules/pdf-host/variables.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module inputs now reject memory_max below 6 MiB while retaining whole MiB/GiB validation; never read by the CARLOS root binary or a box agent at runtime
+
+Seal: `94ccbabaf19c3a449cec248a0c32fcc8593c82d3f7f433c6a48b6e0fdf068167` → `4e67ef2523845a94402c7d37b5d9e1319aa7822fe1e3fef402b65d95acbe6682`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-pdf-host-client-groups.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/infra/modules/pdf-host/README.md b/infra/modules/pdf-host/README.md
index a19a71803..1f3e303a7 100644
--- a/infra/modules/pdf-host/README.md
+++ b/infra/modules/pdf-host/README.md
@@ -2,7 +2,7 @@
This module runs one Gotenberg container on a Debian arm64 EC2 box. The
console sends PDF requests to its private address. TCP 3000 accepts only the
-console's security group. Administration uses SSM Session Manager; the role
+console's security group, plus any groups in `additional_client_security_group_ids`. Administration uses SSM Session Manager; the role
explicitly denies every SSM parameter read and has no bucket grants.
```hcl
@@ -22,6 +22,19 @@ pass `subnet_id` in the client security group's VPC. The subnet needs internet
access for packages, the image and public page assets. It must provide a private
IPv4 address; IPv6-only subnets are unsupported.
+## A standby console
+
+If the console can fail over to a standby box with its own security group,
+admit both from the start, so a failover needs no change here:
+
+```hcl
+ client_security_group_id = module.host_ie.security_group_id
+ additional_client_security_group_ids = [module.standby_ie.security_group_id]
+```
+
+Every additional group must be in the client group's VPC. Adding or removing
+one changes the ingress rule in place; the box and its address stay.
+
## Wiring and replacement
Set the console's `CARLOS_PDF_ADDR` to the module's `pdf_addr` output
diff --git a/infra/modules/pdf-host/main.tf b/infra/modules/pdf-host/main.tf
index 74b181dd7..12c88fdc9 100644
--- a/infra/modules/pdf-host/main.tf
+++ b/infra/modules/pdf-host/main.tf
@@ -2,6 +2,11 @@ data "aws_security_group" "client" {
id = var.client_security_group_id
}
+data "aws_security_group" "additional_client" {
+ for_each = toset(var.additional_client_security_group_ids)
+ id = each.value
+}
+
data "aws_vpc" "client" {
id = data.aws_security_group.client.vpc_id
}
@@ -25,7 +30,7 @@ resource "aws_security_group" "pdf" {
from_port = 3000
to_port = 3000
protocol = "tcp"
- security_groups = [var.client_security_group_id]
+ security_groups = distinct(concat([var.client_security_group_id], var.additional_client_security_group_ids))
}
# Packages, the image and public assets. Administration uses Session Manager.
@@ -37,6 +42,13 @@ resource "aws_security_group" "pdf" {
}
tags = { Name = var.name }
+
+ lifecycle {
+ precondition {
+ condition = alltrue([for g in data.aws_security_group.additional_client : g.vpc_id == data.aws_security_group.client.vpc_id])
+ error_message = "Every additional client security group must be in the client group's VPC; a group in another VPC cannot reach the PDF host."
+ }
+ }
}
resource "aws_iam_role" "pdf" {
diff --git a/infra/modules/pdf-host/tests/pdf_host.tftest.hcl b/infra/modules/pdf-host/tests/pdf_host.tftest.hcl
index c06430366..67e6c432a 100644
--- a/infra/modules/pdf-host/tests/pdf_host.tftest.hcl
+++ b/infra/modules/pdf-host/tests/pdf_host.tftest.hcl
@@ -340,3 +340,46 @@ run "memory_at_or_above_minimum_1G" {
memory_max = "1G"
}
}
+
+run "a_standby_group_is_admitted_too" {
+ command = plan
+ variables {
+ additional_client_security_group_ids = ["sg-0fedcba9876543210"]
+ }
+ override_data {
+ target = data.aws_security_group.additional_client
+ values = { vpc_id = "vpc-0aaaaaaaaaaaaaaaa" }
+ }
+ assert {
+ condition = alltrue([
+ for i in aws_security_group.pdf.ingress :
+ i.from_port == 3000 && i.to_port == 3000 && i.protocol == "tcp"
+ && i.security_groups == toset([var.client_security_group_id, "sg-0fedcba9876543210"])
+ ])
+ error_message = "TCP 3000 from the client group and the standby group only"
+ }
+ assert {
+ condition = length(aws_security_group.pdf.ingress) == 1 && aws_security_group.pdf.vpc_id == "vpc-0aaaaaaaaaaaaaaaa"
+ error_message = "one ingress rule, in the client's VPC"
+ }
+}
+
+run "a_standby_group_in_another_vpc_is_refused" {
+ command = plan
+ variables {
+ additional_client_security_group_ids = ["sg-0fedcba9876543210"]
+ }
+ override_data {
+ target = data.aws_security_group.additional_client
+ values = { vpc_id = "vpc-0bbbbbbbbbbbbbbbb" }
+ }
+ expect_failures = [aws_security_group.pdf]
+}
+
+run "a_malformed_additional_group_is_refused" {
+ command = plan
+ variables {
+ additional_client_security_group_ids = ["not-a-group"]
+ }
+ expect_failures = [var.additional_client_security_group_ids]
+}
diff --git a/infra/modules/pdf-host/variables.tf b/infra/modules/pdf-host/variables.tf
index 991478266..6a1cc28c4 100644
--- a/infra/modules/pdf-host/variables.tf
+++ b/infra/modules/pdf-host/variables.tf
@@ -12,6 +12,16 @@ variable "client_security_group_id" {
type = string
}
+variable "additional_client_security_group_ids" {
+ description = "more security groups that may reach the engine, such as a failover standby console's; each must be in the client group's VPC"
+ type = list(string)
+ default = []
+ validation {
+ condition = alltrue([for id in var.additional_client_security_group_ids : can(regex("^sg-[0-9a-f]+$", id))])
+ error_message = "additional_client_security_group_ids must hold security group ids (sg-...)."
+ }
+}
+
variable "region" {
type = string
validation {
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 431df369d..6d8adde16 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -214,3 +214,4 @@ plan14-root-reads-replica-console-account.tsv 87e151a55efb12fb84e9c5939f2ead9058
plan14-root-reads-offline-move-pool-target-413.tsv f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182
plan14-root-reads-probe-burst-block.tsv 94ccbabaf19c3a449cec248a0c32fcc8593c82d3f7f433c6a48b6e0fdf068167
plan14-root-reads-g6-pool.tsv 94ccbabaf19c3a449cec248a0c32fcc8593c82d3f7f433c6a48b6e0fdf068167
+plan14-root-reads-pdf-host-client-groups.tsv 4e67ef2523845a94402c7d37b5d9e1319aa7822fe1e3fef402b65d95acbe6682
diff --git a/internal/provision/testdata/plan14-root-reads-pdf-host-client-groups.tsv b/internal/provision/testdata/plan14-root-reads-pdf-host-client-groups.tsv
new file mode 100644
index 000000000..538e6f41d
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-pdf-host-client-groups.tsv
@@ -0,0 +1,10 @@
+# Census overlay pdf-host-client-groups, written by census-propose (#369). census-ruling-pdf-host-client-groups, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-pdf-host-client-groups.md.
+# 3 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy 2bee457a3ae615d3c25676d8dd91a37f1caada99727b71d59935b4a054b3a936 infra/modules/pdf-host/main.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module source defining the PDF engine box, security group and SSM-only role; never read by the CARLOS root binary or a box agent at runtime;rev3=census-ruling-pdf-host-client-groups;basis=Adds data.aws_security_group.additional_client (for_each over additional_client_security_group_ids) and admits those groups on TCP 3000 beside the client group; a precondition refuses a group outside the client VPC. No new read by the root binary; the box, role and fence are unchanged. file:external@0 080d7b878a7ee1cd6cfc221a40170440b4cf79299c2c786bbfe249b5dcfd6380
+@legacy 0961cd5371acba68d33f97a1e875efec695a6d1ce15f246320f7b7cfeb8eece2 infra/modules/pdf-host/tests/pdf_host.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=mock-provider tests cover loopback names, mapped IPv6 and userinfo, case-insensitive HTTP, public hostname boundaries and the case-sensitive file exemption; retain private engine-port, metadata/fence retry and Docker memory checks; no live infrastructure calls; never read by the CARLOS root binary or a box agent at runtime;rev3=census-ruling-pdf-host-client-groups;basis=Mock-provider tests for the standby group admitted, a group in another VPC refused, and a malformed id refused. file:external@0 be8460112274bd209d9b5647c85dd5f5bbe6a1f2ff372ff6a34685b40b36cb82
+@legacy 99a4b0ce6d2d679d354d0e4b4921c5dac0ef80abbc10dec8affe0555a9115fcc infra/modules/pdf-host/variables.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module inputs now reject memory_max below 6 MiB while retaining whole MiB/GiB validation; never read by the CARLOS root binary or a box agent at runtime;rev3=census-ruling-pdf-host-client-groups;basis=New optional input additional_client_security_group_ids (list of sg ids, default empty, validated as sg-...). No new read. file:external@0 aa6b7ecfd8f82491063afc57fab57d8017c5e80fdf9fbfe1e504fdcc929f10b9
+infra/modules/pdf-host/main.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module source defining the PDF engine box, security group and SSM-only role; never read by the CARLOS root binary or a box agent at runtime;rev3=census-ruling-pdf-host-client-groups;basis=Adds data.aws_security_group.additional_client (for_each over additional_client_security_group_ids) and admits those groups on TCP 3000 beside the client group; a precondition refuses a group outside the client VPC. No new read by the root binary; the box, role and fence are unchanged. file:external@0 080d7b878a7ee1cd6cfc221a40170440b4cf79299c2c786bbfe249b5dcfd6380
+infra/modules/pdf-host/tests/pdf_host.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=mock-provider tests cover loopback names, mapped IPv6 and userinfo, case-insensitive HTTP, public hostname boundaries and the case-sensitive file exemption; retain private engine-port, metadata/fence retry and Docker memory checks; no live infrastructure calls; never read by the CARLOS root binary or a box agent at runtime;rev3=census-ruling-pdf-host-client-groups;basis=Mock-provider tests for the standby group admitted, a group in another VPC refused, and a malformed id refused. file:external@0 be8460112274bd209d9b5647c85dd5f5bbe6a1f2ff372ff6a34685b40b36cb82
+infra/modules/pdf-host/variables.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module inputs now reject memory_max below 6 MiB while retaining whole MiB/GiB validation; never read by the CARLOS root binary or a box agent at runtime;rev3=census-ruling-pdf-host-client-groups;basis=New optional input additional_client_security_group_ids (list of sg ids, default empty, validated as sg-...). No new read. file:external@0 aa6b7ecfd8f82491063afc57fab57d8017c5e80fdf9fbfe1e504fdcc929f10b9
+@coverage infra/modules/pdf-host fbab1c79b6df254a19cc147605b8883dfda3479aec35725a2d634c7b20f24858
+@coverage infra/modules/pdf-host/tests 3cbb616d9f9a7e0f49950b95a9787f6a22f39d3b61c19f9989fb88f09aace422