region-host: fixed-box status-check alarms notify; reboot alarm
On 2026-11-09 a dev box sat impaired about nine hours: its only health alarm was StatusCheckFailed_System -> ec2:recover with no SNS action, and the recover failed silently. - auto-recover alarm: alerts topic on alarm_actions and ok_actions; ec2:recover kept. - new <name>-instance-check alarm (fixed mode, same gate): StatusCheckFailed_Instance 3 of 3 x 60 s -> ec2:reboot + topic, ok -> topic; recover stays 2 x 60 s so it acts first. - new input health_alerts_topic_arn for these two alarms only (no memory alarm, no publish grant); empty falls back to the alerts topic. - tests/health_alarms.tftest.hcl; census ruling census-ruling-fixedbox-health-alarms (Astra, #280). Reviewed by Astra, three rounds, READY at 0065c957. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from fixedbox-health-alarms into main.
7 files changed,
+327
−2
docs/superpowers/notes/census-proposal-fixedbox-health-alarms.md+27 −0infra/modules/region-host/alert_publish.tf+1 −0infra/modules/region-host/main.tf+34 −1infra/modules/region-host/tests/health_alarms.tftest.hcl+236 −0infra/modules/region-host/variables.tf+15 −1internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-fixedbox-health-alarms.tsv+13 −0
CI failed — run details
diff --git a/docs/superpowers/notes/census-proposal-fixedbox-health-alarms.md b/docs/superpowers/notes/census-proposal-fixedbox-health-alarms.md| new file mode 100644 |
| index 000000000..dd7ae50da |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-fixedbox-health-alarms.md |
| @@ -0,0 +1,27 @@ |
| +# Census approval: fixedbox-health-alarms |
| + |
| +Ruling `census-ruling-fixedbox-health-alarms`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `infra/modules/region-host/alert_publish.tf` `external` | body | unchanged (1) | Add local.health_alerts_actions: the optional health_alerts_topic_arn, else the existing alerts topic selection. Notification target for CloudWatch alarms only; no grant, no runtime sink, no new root read. | |
| +| `infra/modules/region-host/main.tf` `external` | body | unchanged (1) | Fixed host EC2 status-check alarms: auto-recover gains SNS alarm/ok actions (ec2:recover kept); new host_instance_check alarm (StatusCheckFailed_Instance 3 of 3 x 60 s -> ec2:reboot + SNS). tofu only, run on an operator machine; no read is added and nothing on a box reads the file. | |
| +| `infra/modules/region-host/variables.tf` `external` | body | unchanged (1) | Add optional health_alerts_topic_arn (concrete same-region SNS ARN validation, empty default); enable_auto_recovery description covers both status alarms. Operator Terraform input; no box runtime read. | |
| + |
| +Envelopes re-pinned: `infra/modules/region-host`, `infra/modules/region-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/region-host/alert_publish.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-g2-fixes;basis=New host-role inline policy grants only sns:Publish on the union of the module alerts topic and explicit additional topic ARNs, in fixed and group mode; no runtime sink configuration, termination or storage permission. Operator Terraform input, no box runtime read.;rev3=census-ruling-region-ha-g3-fixes;basis=Select either an operator-provided existing regional SNS topic or the module-created topic; grant sns:Publish only on that selected topic plus explicit additional topic ARNs. No new root runtime read, storage permission or sink configuration. |
| +- `infra/modules/region-host/main.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-console-invite-delivery;basis=tofu on an operator's machine with the operator's AWS credentials (no box unit; no binary embeds the file): main's module with one optional aws_iam_role_policy, host_console_mail, count 0 unless console_mail_from is set; it grants the host role ses:SendEmail on the one sending identity, the carlos-bab configuration set and its tenants, conditioned on ses:FromAddress equal to console_mail_from; no read is added and nothing on a box reads the file;rev3=census-ruling-sec-host-imdsv2-module;basis=aws_instance.host gains metadata_options (IMDSv2 required, hop limit 1, endpoint enabled), matching scanner-host; tofu configuration only, run on an operator's machine; no read, file or record write is added; applies in place on a running instance with no restart;rev3=census-ruling-hunt-account-root-hardening;basis=adds aws_iam_role_policy host_release_key_deny (count from deny_release_key_reads, default true): an explicit Deny on ssm:GetParameter, GetParameters and GetParameterHistory for parameter/carlos/release-key, and on GetParametersByPath for its ancestor paths; tofu only, run on an operator's machine; no read is added and nothing on a box reads the file;rev3=census-ruling-region-host-store-deny;basis=host_store policy: the explicit Deny on the deployment's own buckets drops s3:DeleteObject and keeps s3:DeleteBucket and s3:CreateBucket (lease release, retention and prune are DeleteObject); tofu only, run on an operator machine; no read is added and nothing on a box reads the file;rev3=census-ruling-region-ha-p3b;basis=Select default fixed resources through counted addresses and explicit moves; group mode selects scoped bucket/SSM policy, partition-aware ARNs and refuses fixed-only settings. Operator Terraform controls the instance role that can read boot parameters and write runtime bucket objects; release-key Deny and fixed-mode policy remain.;rev3=census-ruling-region-ha-g3-fixes;basis=Enable the fixed-host memory alarm with either alert input and use the selected topic for alarm and recovery notifications. Preserve module topic/subscription creation for alerts_email only. No new root runtime read or box authority.;rev3=census-ruling-managed-fleets-2b1;basis=managed fleets 2b-1 Task 5: aws_iam_policy.store_user_boundary is now counted when store_bucket_prefix is set or managed_fleets_enabled is true; its statements are concat of the unchanged object-storage pair (only with a store prefix, moved into local.store_boundary_statements byte for byte) and local.managed_boundary_statements (only with managed fleets: the fleet-data Allows on <managed_fleet_bucket_prefix>* buckets); name unchanged, description conditional on store prefix with lifecycle ignore_changes on description so a later feature switch never replaces the policy; tofu only, run on an operator's machine with the operator's AWS credentials; no box unit, user_data or binary reads the file; no read is added; default (both features off) plans no change |
| +- `infra/modules/region-host/variables.tf` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-console-invite-delivery;basis=tofu on an operator's machine with the operator's AWS credentials (no box unit; no binary embeds the file): main's variables with console_mail_from (validated as one lowercase address) and console_mail_region, both empty by default; no read is added and nothing on a box reads the file;rev3=census-ruling-hunt-account-root-hardening;basis=adds deny_release_key_reads (bool, default true); no read is added and nothing on a box reads the file;rev3=census-ruling-region-ha-p3b;basis=Add default-fixed mode and validated group count, zones, pinned image/release/template, ingress, configuration key and transaction-open refusal. Operator-supplied Terraform values select root boot inputs; no direct box runtime read and no group activation by default.;rev3=census-ruling-region-ha-g2-fixes;basis=Add an empty-default set of additional alert topic ARNs, validating concrete SNS topic syntax and excluding wildcards/subscriptions; operator Terraform input, no box runtime read.;rev3=census-ruling-region-ha-g3-fixes;basis=Add optional alerts_topic_arn with concrete same-region SNS ARN validation and mutual exclusion with alerts_email. The caller owns the existing topic policy and subscriptions; no runtime sink is configured and no new root read is added.;rev3=census-ruling-managed-fleets-2b1;basis=managed fleets 2b-1 Task 5: five variables, managed_fleets_enabled (bool, default false, refused unless mode is fixed), managed_fleets_deployment, managed_fleets_regions (concrete ami/subnet/sg IDs, arm64 types, no ID in two regions), managed_fleet_bucket_prefix (1-24 chars, no reserved prefix, must not cover the deployment, data or staging buckets, disjoint from store_bucket_prefix) and managed_fleet_user_path (literal IAM path, disjoint from store_user_path); store_bucket_prefix and store_user_path gain a validation refusing *, ? or ${ only when managed fleets and object storage are both on; operator Terraform input only; no box runtime read and nothing on a box reads the file |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `infra/modules/region-host/tests/health_alarms.tftest.hcl:external`: reads +file:external; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `beb085e4c6cdb3d430d12a8dc3c93f25cc3faf1aa7d62be37698ff9c9c82ecce` → `0f7153571df8c1b4b50c31f57efcfdf60c71a12c80fd935fb3ea202fa0201dd5`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-fixedbox-health-alarms.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/infra/modules/region-host/alert_publish.tf b/infra/modules/region-host/alert_publish.tf| index 8bce58495..4d42d1f84 100644 |
| --- a/infra/modules/region-host/alert_publish.tf |
| +++ b/infra/modules/region-host/alert_publish.tf |
| @@ -2,6 +2,7 @@ locals { |
| alerts_enabled = var.alerts_topic_arn != "" || var.alerts_email != "" |
| alerts_topic_arn = var.alerts_topic_arn != "" ? var.alerts_topic_arn : one(aws_sns_topic.alerts[*].arn) |
| alerts_actions = local.alerts_enabled ? [local.alerts_topic_arn] : [] |
| + health_alerts_actions = var.health_alerts_topic_arn != "" ? [var.health_alerts_topic_arn] : local.alerts_actions |
| alert_publish_topic_arns = setunion(var.alert_publish_topic_arns, toset(local.alerts_actions)) |
| } |
diff --git a/infra/modules/region-host/main.tf b/infra/modules/region-host/main.tf| index 5ebe466f0..dd749ba85 100644 |
| --- a/infra/modules/region-host/main.tf |
| +++ b/infra/modules/region-host/main.tf |
| @@ -607,6 +607,11 @@ resource "aws_eip" "host" { |
| # HA ladder rung 0 (2026-08-12 spec): system-status failure recovers the |
| # instance onto healthy hardware, keeping instance id, EIP and volumes. |
| +# |
| +# Both status alarms also tell someone (local.health_alerts_actions). On |
| +# 2026-11-09 a dev box sat impaired for about nine hours: the recover action |
| +# fired, failed, and nothing else happened, because these alarms had no |
| +# notification. An alarm with only an EC2 action fails silently. |
| resource "aws_cloudwatch_metric_alarm" "host_auto_recover" { |
| count = var.mode == "fixed" && var.enable_auto_recovery ? 1 : 0 |
| alarm_name = "${var.name}-auto-recover" |
| @@ -618,13 +623,41 @@ resource "aws_cloudwatch_metric_alarm" "host_auto_recover" { |
| evaluation_periods = 2 |
| threshold = 1 |
| comparison_operator = "GreaterThanOrEqualToThreshold" |
| - alarm_actions = ["arn:aws:automate:${data.aws_region.current.region}:ec2:recover"] |
| + alarm_actions = concat(["arn:aws:automate:${data.aws_region.current.region}:ec2:recover"], local.health_alerts_actions) |
| + ok_actions = local.health_alerts_actions |
| dimensions = { |
| InstanceId = aws_instance.host[0].id |
| } |
| tags = { Name = "${var.name}-auto-recover" } |
| } |
| +# The other half of the status checks: the hardware is fine but the guest has |
| +# stopped answering (kernel hang, exhausted memory, broken network config). |
| +# EC2's own remedy for that is a reboot; recover does not apply. A system |
| +# failure usually fails the instance check too, so this alarm waits three |
| +# minutes to the recover alarm's two: recover goes first, as AWS advises, |
| +# rather than racing a reboot on the same impaired box. |
| +resource "aws_cloudwatch_metric_alarm" "host_instance_check" { |
| + count = var.mode == "fixed" && var.enable_auto_recovery ? 1 : 0 |
| + alarm_name = "${var.name}-instance-check" |
| + alarm_description = "EC2 instance-status-check failure on ${var.name} for 3 minutes: the box is rebooted. If it fails again after the reboot, read the instance's console output." |
| + namespace = "AWS/EC2" |
| + metric_name = "StatusCheckFailed_Instance" |
| + statistic = "Maximum" |
| + period = 60 |
| + evaluation_periods = 3 |
| + datapoints_to_alarm = 3 |
| + threshold = 1 |
| + comparison_operator = "GreaterThanOrEqualToThreshold" |
| + treat_missing_data = "missing" |
| + alarm_actions = concat(["arn:aws:automate:${data.aws_region.current.region}:ec2:reboot"], local.health_alerts_actions) |
| + ok_actions = local.health_alerts_actions |
| + dimensions = { |
| + InstanceId = aws_instance.host[0].id |
| + } |
| + tags = { Name = "${var.name}-instance-check" } |
| +} |
| + |
| # Memory-pressure spec §2.4: the early warning the status checks can't give. |
| # On 2026-08-28 the flagship thrashed for 15 minutes with EC2 status ok/ok; |
| # MemAvailable would have crossed 15% minutes earlier. Missing data is |
diff --git a/infra/modules/region-host/tests/health_alarms.tftest.hcl b/infra/modules/region-host/tests/health_alarms.tftest.hcl| new file mode 100644 |
| index 000000000..bf587613b |
| --- /dev/null |
| +++ b/infra/modules/region-host/tests/health_alarms.tftest.hcl |
| @@ -0,0 +1,236 @@ |
| +# Plan-time tests for the fixed host's EC2 status-check alarms: each one |
| +# keeps its EC2 action and tells someone. mock_provider: no AWS account. |
| +mock_provider "aws" { |
| + mock_data "aws_region" { defaults = { region = "eu-west-1" } } |
| +} |
| + |
| +override_data { |
| + target = data.aws_vpcs.default |
| + values = { ids = ["vpc-0aaaaaaaaaaaaaaaa"] } |
| +} |
| + |
| +override_data { |
| + target = data.aws_caller_identity.current |
| + values = { account_id = "123456789012" } |
| +} |
| + |
| +# The termination queue's ARN feeds an EventBridge target, which the provider |
| +# validates as an ARN; the mock's random string is not one. |
| +override_resource { |
| + target = aws_sqs_queue.terminations |
| + values = { arn = "arn:aws:sqs:eu-west-1:123456789012:carlos-test-host-terminations" } |
| +} |
| + |
| +variables { |
| + name = "carlos-test-ie" |
| + sg_description = "carlos test host" |
| + iam_name = "carlos-test-host" |
| + instance_type = "t4g.small" |
| + root_volume_size = 20 |
| + user_data = "#!/bin/sh\n" |
| + deployment_bucket_arn = "arn:aws:s3:::carlos-test-platform" |
| + data_bucket_arn = "arn:aws:s3:::carlos-test-ie" |
| + ssm_parameter_arn = "arn:aws:ssm:eu-west-1:123456789012:parameter/carlos/*" |
| +} |
| + |
| + |
| +override_data { |
| + target = data.aws_ami.debian_arm64 |
| + values = { id = "ami-0123456789abcdef0" } |
| +} |
| +override_data { |
| + target = data.aws_vpc.host |
| + values = { cidr_block = "10.0.0.0/16" } |
| +} |
| +override_resource { |
| + target = aws_instance.host |
| + values = { id = "i-0123456789abcdef0" } |
| +} |
| +override_resource { |
| + target = aws_security_group.host |
| + values = { id = "sg-0123456789abcdef0" } |
| +} |
| +override_resource { |
| + target = aws_iam_role.host |
| + values = { arn = "arn:aws:iam::123456789012:role/carlos-test-host" } |
| +} |
| +override_resource { |
| + target = aws_eip.host |
| + values = { public_ip = "192.0.2.10" } |
| +} |
| +override_resource { |
| + target = aws_sns_topic.alerts |
| + values = { arn = "arn:aws:sns:eu-west-1:123456789012:carlos-test-ie-alerts" } |
| +} |
| + |
| +run "status_alarms_without_any_topic" { |
| + command = plan |
| + assert { |
| + condition = ( |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:recover"]) && |
| + length(aws_cloudwatch_metric_alarm.host_auto_recover[0].ok_actions) == 0 && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:reboot"]) && |
| + length(aws_cloudwatch_metric_alarm.host_instance_check[0].ok_actions) == 0 |
| + ) |
| + error_message = "with no topic configured the status alarms keep only their EC2 actions" |
| + } |
| + assert { |
| + condition = ( |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].alarm_name == "carlos-test-ie-instance-check" && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].namespace == "AWS/EC2" && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].metric_name == "StatusCheckFailed_Instance" && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].statistic == "Maximum" && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].period == 60 && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].evaluation_periods == 3 && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].datapoints_to_alarm == 3 && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].threshold == 1 && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].comparison_operator == "GreaterThanOrEqualToThreshold" && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].treat_missing_data == "missing" && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].dimensions == tomap({ InstanceId = "i-0123456789abcdef0" }) |
| + ) |
| + error_message = "instance-check alarm must watch this instance's instance status check, 3 of 3 one-minute periods" |
| + } |
| + assert { |
| + condition = ( |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].metric_name == "StatusCheckFailed_System" && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].period == 60 && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].evaluation_periods == 2 && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].evaluation_periods < aws_cloudwatch_metric_alarm.host_instance_check[0].evaluation_periods && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].dimensions == tomap({ InstanceId = "i-0123456789abcdef0" }) |
| + ) |
| + error_message = "auto-recover alarm's metric and timing must not change, and it must fire before the reboot alarm" |
| + } |
| +} |
| + |
| +run "status_alarms_use_the_alerts_email_topic" { |
| + command = plan |
| + variables { |
| + alerts_email = "ops@example.com" |
| + } |
| + assert { |
| + condition = ( |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:recover", "arn:aws:sns:eu-west-1:123456789012:carlos-test-ie-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:carlos-test-ie-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:reboot", "arn:aws:sns:eu-west-1:123456789012:carlos-test-ie-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:carlos-test-ie-alerts"]) |
| + ) |
| + error_message = "status alarms must notify the module's alerts topic on alarm and on clear" |
| + } |
| +} |
| + |
| +run "status_alarms_use_the_alerts_topic_arn" { |
| + command = plan |
| + variables { |
| + alerts_topic_arn = "arn:aws:sns:eu-west-1:123456789012:permanent-ha-alerts" |
| + } |
| + assert { |
| + condition = ( |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:recover", "arn:aws:sns:eu-west-1:123456789012:permanent-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:permanent-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:reboot", "arn:aws:sns:eu-west-1:123456789012:permanent-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:permanent-ha-alerts"]) |
| + ) |
| + error_message = "status alarms must notify the selected alerts topic" |
| + } |
| +} |
| + |
| +# The dev case: a box with no memory alarm and no publish grant, told through |
| +# a topic the deployment owns. |
| +run "health_topic_alone_arms_nothing_else" { |
| + command = plan |
| + variables { |
| + health_alerts_topic_arn = "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts" |
| + } |
| + assert { |
| + condition = ( |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:recover", "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:reboot", "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) |
| + ) |
| + error_message = "status alarms must notify the health topic" |
| + } |
| + assert { |
| + condition = ( |
| + length(aws_cloudwatch_metric_alarm.host_memory_low) == 0 && |
| + length(aws_iam_role_policy.alert_publish) == 0 && |
| + length(aws_sns_topic.alerts) == 0 && |
| + output.alerts_topic_arn == null |
| + ) |
| + error_message = "the health topic must not arm the memory alarm, grant publish, or create a topic" |
| + } |
| +} |
| + |
| +run "health_topic_overrides_the_alerts_email_topic" { |
| + command = plan |
| + variables { |
| + alerts_email = "ops@example.com" |
| + health_alerts_topic_arn = "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts" |
| + } |
| + assert { |
| + condition = ( |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:recover", "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:reboot", "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_memory_low[0].alarm_actions == toset(["arn:aws:sns:eu-west-1:123456789012:carlos-test-ie-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_memory_low[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:carlos-test-ie-alerts"]) |
| + ) |
| + error_message = "the health topic takes the status alarms; the memory alarm keeps the alerts topic" |
| + } |
| +} |
| + |
| +run "health_topic_overrides_the_alerts_topic_arn" { |
| + command = plan |
| + variables { |
| + alerts_topic_arn = "arn:aws:sns:eu-west-1:123456789012:permanent-ha-alerts" |
| + health_alerts_topic_arn = "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts" |
| + } |
| + assert { |
| + condition = ( |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:recover", "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].alarm_actions == toset(["arn:aws:automate:eu-west-1:ec2:reboot", "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_memory_low[0].alarm_actions == toset(["arn:aws:sns:eu-west-1:123456789012:permanent-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_auto_recover[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_instance_check[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts"]) && |
| + aws_cloudwatch_metric_alarm.host_memory_low[0].ok_actions == toset(["arn:aws:sns:eu-west-1:123456789012:permanent-ha-alerts"]) |
| + ) |
| + error_message = "the health topic takes the status alarms; the memory alarm keeps the alerts topic" |
| + } |
| +} |
| + |
| +run "auto_recovery_off_arms_neither_status_alarm" { |
| + command = plan |
| + variables { |
| + enable_auto_recovery = false |
| + health_alerts_topic_arn = "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts" |
| + } |
| + assert { |
| + condition = length(aws_cloudwatch_metric_alarm.host_auto_recover) == 0 && length(aws_cloudwatch_metric_alarm.host_instance_check) == 0 |
| + error_message = "enable_auto_recovery = false must arm neither status alarm" |
| + } |
| +} |
| + |
| +run "health_topic_wrong_region" { |
| + command = plan |
| + variables { |
| + health_alerts_topic_arn = "arn:aws:sns:eu-west-2:123456789012:dev-ha-alerts" |
| + } |
| + expect_failures = [var.health_alerts_topic_arn] |
| +} |
| + |
| +run "health_topic_wildcard" { |
| + command = plan |
| + variables { |
| + health_alerts_topic_arn = "arn:aws:sns:eu-west-1:123456789012:dev-ha-*" |
| + } |
| + expect_failures = [var.health_alerts_topic_arn] |
| +} |
| + |
| +run "health_topic_subscription_suffix" { |
| + command = plan |
| + variables { |
| + health_alerts_topic_arn = "arn:aws:sns:eu-west-1:123456789012:dev-ha-alerts:0f1e2d3c-aaaa-bbbb-cccc-123456789012" |
| + } |
| + expect_failures = [var.health_alerts_topic_arn] |
| +} |
diff --git a/infra/modules/region-host/variables.tf b/infra/modules/region-host/variables.tf| index 7de97fd8d..ad57700c7 100644 |
| --- a/infra/modules/region-host/variables.tf |
| +++ b/infra/modules/region-host/variables.tf |
| @@ -195,7 +195,7 @@ variable "steering_record_names" { |
| } |
| variable "enable_auto_recovery" { |
| - description = "Arm an EC2 auto-recovery alarm on the host (HA ladder rung 0)." |
| + description = "Arm the host's EC2 status-check alarms (HA ladder rung 0): a system-check failure recovers the instance, an instance-check failure reboots it." |
| type = bool |
| default = true |
| } |
| @@ -230,6 +230,20 @@ variable "alerts_topic_arn" { |
| } |
| } |
| +variable "health_alerts_topic_arn" { |
| + description = "SNS topic ARN told when a fixed host's EC2 status-check alarms fire or clear. Empty means the alerts topic from alerts_topic_arn or alerts_email, when one is set. Unlike alerts_topic_arn, this input arms no memory alarm and grants the host no publish right. The topic must be in this module's AWS region; its policy must let CloudWatch alarms publish, and the caller manages it." |
| + type = string |
| + default = "" |
| + nullable = false |
| + validation { |
| + condition = var.health_alerts_topic_arn == "" || ( |
| + can(regex("^arn:aws(-[a-z]+)*:sns:[a-z]{2}(-[a-z]+)+-[0-9]+:[0-9]{12}:([A-Za-z0-9_-]{1,256}|[A-Za-z0-9_-]{1,251}\\.fifo)$", var.health_alerts_topic_arn)) && |
| + try(split(":", var.health_alerts_topic_arn)[3] == data.aws_region.current.region, false) |
| + ) |
| + error_message = "health_alerts_topic_arn must be a concrete SNS topic ARN in this module's AWS region, without wildcards or a subscription suffix." |
| + } |
| +} |
| + |
| variable "alert_publish_topic_arns" { |
| description = "Additional SNS topic ARNs the host may publish alerts to. This grant does not configure CARLOS_ALERT_SNS_TOPIC_ARN." |
| type = set(string) |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 6ef8a02df..4eab739b6 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -138,3 +138,4 @@ plan14-root-reads-gvisor-demos.tsv f05716181a82721b38cba9b2d89c47925dc2ca426e5c4 |
| plan14-root-reads-dns-fresh-lookup-724.tsv 7ac2bde8301c37c7546e9aa19d375f1468fc8061876a618fa8f93dd4543c5652 |
| plan14-root-reads-gvisor-update-dirs.tsv 1f1b2fdb569b7be42e75e10d1943d7e512708299364f912c2f72dccf1bd5b678 |
| plan14-root-reads-region-ha-held-build.tsv beb085e4c6cdb3d430d12a8dc3c93f25cc3faf1aa7d62be37698ff9c9c82ecce |
| +plan14-root-reads-fixedbox-health-alarms.tsv 0f7153571df8c1b4b50c31f57efcfdf60c71a12c80fd935fb3ea202fa0201dd5 |
diff --git a/internal/provision/testdata/plan14-root-reads-fixedbox-health-alarms.tsv b/internal/provision/testdata/plan14-root-reads-fixedbox-health-alarms.tsv| new file mode 100644 |
| index 000000000..2bf51fd36 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-fixedbox-health-alarms.tsv |
| @@ -0,0 +1,13 @@ |
| +# Census overlay fixedbox-health-alarms, written by census-propose (#369). census-ruling-fixedbox-health-alarms, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-fixedbox-health-alarms.md. |
| +# 3 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +@legacy 0952ff5bfd88f8019984ffc93bafeb7e239ba8390d66ad188c24ddde3e8190c1 infra/modules/region-host/alert_publish.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-g2-fixes;basis=New host-role inline policy grants only sns:Publish on the union of the module alerts topic and explicit additional topic ARNs, in fixed and group mode; no runtime sink configuration, termination or storage permission. Operator Terraform input, no box runtime read.;rev3=census-ruling-region-ha-g3-fixes;basis=Select either an operator-provided existing regional SNS topic or the module-created topic; grant sns:Publish only on that selected topic plus explicit additional topic ARNs. No new root runtime read, storage permission or sink configuration.;rev3=census-ruling-fixedbox-health-alarms;basis=Add local.health_alerts_actions: the optional health_alerts_topic_arn, else the existing alerts topic selection. Notification target for CloudWatch alarms only; no grant, no runtime sink, no new root read. file:external@0 ecc15879a119f4c6e64ad2bc02a50b16e4c2f1f9537f32369a2737c592683a2f |
| +@legacy 285b1691c2e129853843b9d874cf2fa4c5f6d9bd608dc1a3046446fb7e258a0e infra/modules/region-host/main.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-console-invite-delivery;basis=tofu on an operator's machine with the operator's AWS credentials (no box unit; no binary embeds the file): main's module with one optional aws_iam_role_policy, host_console_mail, count 0 unless console_mail_from is set; it grants the host role ses:SendEmail on the one sending identity, the carlos-bab configuration set and its tenants, conditioned on ses:FromAddress equal to console_mail_from; no read is added and nothing on a box reads the file;rev3=census-ruling-sec-host-imdsv2-module;basis=aws_instance.host gains metadata_options (IMDSv2 required, hop limit 1, endpoint enabled), matching scanner-host; tofu configuration only, run on an operator's machine; no read, file or record write is added; applies in place on a running instance with no restart;rev3=census-ruling-hunt-account-root-hardening;basis=adds aws_iam_role_policy host_release_key_deny (count from deny_release_key_reads, default true): an explicit Deny on ssm:GetParameter, GetParameters and GetParameterHistory for parameter/carlos/release-key, and on GetParametersByPath for its ancestor paths; tofu only, run on an operator's machine; no read is added and nothing on a box reads the file;rev3=census-ruling-region-host-store-deny;basis=host_store policy: the explicit Deny on the deployment's own buckets drops s3:DeleteObject and keeps s3:DeleteBucket and s3:CreateBucket (lease release, retention and prune are DeleteObject); tofu only, run on an operator machine; no read is added and nothing on a box reads the file;rev3=census-ruling-region-ha-p3b;basis=Select default fixed resources through counted addresses and explicit moves; group mode selects scoped bucket/SSM policy, partition-aware ARNs and refuses fixed-only settings. Operator Terraform controls the instance role that can read boot parameters and write runtime bucket objects; release-key Deny and fixed-mode policy remain.;rev3=census-ruling-region-ha-g3-fixes;basis=Enable the fixed-host memory alarm with either alert input and use the selected topic for alarm and recovery notifications. Preserve module topic/subscription creation for alerts_email only. No new root runtime read or box authority.;rev3=census-ruling-managed-fleets-2b1;basis=managed fleets 2b-1 Task 5: aws_iam_policy.store_user_boundary is now counted when store_bucket_prefix is set or managed_fleets_enabled is true; its statements are concat of the unchanged object-storage pair (only with a store prefix, moved into local.store_boundary_statements byte for byte) and local.managed_boundary_statements (only with managed fleets: the fleet-data Allows on <managed_fleet_bucket_prefix>* buckets); name unchanged, description conditional on store prefix with lifecycle ignore_changes on description so a later feature switch never replaces the policy; tofu only, run on an operator's machine with the operator's AWS credentials; no box unit, user_data or binary reads the file; no read is added; default (both features off) plans no change;rev3=census-ruling-fixedbox-health-alarms;basis=Fixed host EC2 status-check alarms: auto-recover gains SNS alarm/ok actions (ec2:recover kept); new host_instance_check alarm (StatusCheckFailed_Instance 3 of 3 x 60 s -> ec2:reboot + SNS). tofu only, run on an operator machine; no read is added and nothing on a box reads the file. file:external@0 9a853f2ebe04ad817b318b699a0338fff391bb293251867507c8a470bbf1be13 |
| +@legacy 26fa412ab87203c236233e0f913067b2c33f7ec5e4d52bca08e2239ae6e3d6aa infra/modules/region-host/variables.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-console-invite-delivery;basis=tofu on an operator's machine with the operator's AWS credentials (no box unit; no binary embeds the file): main's variables with console_mail_from (validated as one lowercase address) and console_mail_region, both empty by default; no read is added and nothing on a box reads the file;rev3=census-ruling-hunt-account-root-hardening;basis=adds deny_release_key_reads (bool, default true); no read is added and nothing on a box reads the file;rev3=census-ruling-region-ha-p3b;basis=Add default-fixed mode and validated group count, zones, pinned image/release/template, ingress, configuration key and transaction-open refusal. Operator-supplied Terraform values select root boot inputs; no direct box runtime read and no group activation by default.;rev3=census-ruling-region-ha-g2-fixes;basis=Add an empty-default set of additional alert topic ARNs, validating concrete SNS topic syntax and excluding wildcards/subscriptions; operator Terraform input, no box runtime read.;rev3=census-ruling-region-ha-g3-fixes;basis=Add optional alerts_topic_arn with concrete same-region SNS ARN validation and mutual exclusion with alerts_email. The caller owns the existing topic policy and subscriptions; no runtime sink is configured and no new root read is added.;rev3=census-ruling-managed-fleets-2b1;basis=managed fleets 2b-1 Task 5: five variables, managed_fleets_enabled (bool, default false, refused unless mode is fixed), managed_fleets_deployment, managed_fleets_regions (concrete ami/subnet/sg IDs, arm64 types, no ID in two regions), managed_fleet_bucket_prefix (1-24 chars, no reserved prefix, must not cover the deployment, data or staging buckets, disjoint from store_bucket_prefix) and managed_fleet_user_path (literal IAM path, disjoint from store_user_path); store_bucket_prefix and store_user_path gain a validation refusing *, ? or ${ only when managed fleets and object storage are both on; operator Terraform input only; no box runtime read and nothing on a box reads the file;rev3=census-ruling-fixedbox-health-alarms;basis=Add optional health_alerts_topic_arn (concrete same-region SNS ARN validation, empty default); enable_auto_recovery description covers both status alarms. Operator Terraform input; no box runtime read. file:external@0 cc573d8d025df8b036346236815e3f08772b49cadcc504ae7ec2e4bafafffc14 |
| +@legacy 83d46fc2a63a54985d4b292afd9fcd54e1c98d8b8366fff3daf96270df306ae9 infra/modules/region-host/tests/health_alarms.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-fixedbox-health-alarms;basis=New mock-provider tofu test file for the status-check alarms; runs only under tofu test on a developer machine, nothing on a box reads it. file:external@0 0c526103bbe8cdb69222da5015cadf7ae3350bc0688abf732222b73480f67550 |
| +infra/modules/region-host/alert_publish.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-g2-fixes;basis=New host-role inline policy grants only sns:Publish on the union of the module alerts topic and explicit additional topic ARNs, in fixed and group mode; no runtime sink configuration, termination or storage permission. Operator Terraform input, no box runtime read.;rev3=census-ruling-region-ha-g3-fixes;basis=Select either an operator-provided existing regional SNS topic or the module-created topic; grant sns:Publish only on that selected topic plus explicit additional topic ARNs. No new root runtime read, storage permission or sink configuration.;rev3=census-ruling-fixedbox-health-alarms;basis=Add local.health_alerts_actions: the optional health_alerts_topic_arn, else the existing alerts topic selection. Notification target for CloudWatch alarms only; no grant, no runtime sink, no new root read. file:external@0 ecc15879a119f4c6e64ad2bc02a50b16e4c2f1f9537f32369a2737c592683a2f |
| +infra/modules/region-host/main.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-console-invite-delivery;basis=tofu on an operator's machine with the operator's AWS credentials (no box unit; no binary embeds the file): main's module with one optional aws_iam_role_policy, host_console_mail, count 0 unless console_mail_from is set; it grants the host role ses:SendEmail on the one sending identity, the carlos-bab configuration set and its tenants, conditioned on ses:FromAddress equal to console_mail_from; no read is added and nothing on a box reads the file;rev3=census-ruling-sec-host-imdsv2-module;basis=aws_instance.host gains metadata_options (IMDSv2 required, hop limit 1, endpoint enabled), matching scanner-host; tofu configuration only, run on an operator's machine; no read, file or record write is added; applies in place on a running instance with no restart;rev3=census-ruling-hunt-account-root-hardening;basis=adds aws_iam_role_policy host_release_key_deny (count from deny_release_key_reads, default true): an explicit Deny on ssm:GetParameter, GetParameters and GetParameterHistory for parameter/carlos/release-key, and on GetParametersByPath for its ancestor paths; tofu only, run on an operator's machine; no read is added and nothing on a box reads the file;rev3=census-ruling-region-host-store-deny;basis=host_store policy: the explicit Deny on the deployment's own buckets drops s3:DeleteObject and keeps s3:DeleteBucket and s3:CreateBucket (lease release, retention and prune are DeleteObject); tofu only, run on an operator machine; no read is added and nothing on a box reads the file;rev3=census-ruling-region-ha-p3b;basis=Select default fixed resources through counted addresses and explicit moves; group mode selects scoped bucket/SSM policy, partition-aware ARNs and refuses fixed-only settings. Operator Terraform controls the instance role that can read boot parameters and write runtime bucket objects; release-key Deny and fixed-mode policy remain.;rev3=census-ruling-region-ha-g3-fixes;basis=Enable the fixed-host memory alarm with either alert input and use the selected topic for alarm and recovery notifications. Preserve module topic/subscription creation for alerts_email only. No new root runtime read or box authority.;rev3=census-ruling-managed-fleets-2b1;basis=managed fleets 2b-1 Task 5: aws_iam_policy.store_user_boundary is now counted when store_bucket_prefix is set or managed_fleets_enabled is true; its statements are concat of the unchanged object-storage pair (only with a store prefix, moved into local.store_boundary_statements byte for byte) and local.managed_boundary_statements (only with managed fleets: the fleet-data Allows on <managed_fleet_bucket_prefix>* buckets); name unchanged, description conditional on store prefix with lifecycle ignore_changes on description so a later feature switch never replaces the policy; tofu only, run on an operator's machine with the operator's AWS credentials; no box unit, user_data or binary reads the file; no read is added; default (both features off) plans no change;rev3=census-ruling-fixedbox-health-alarms;basis=Fixed host EC2 status-check alarms: auto-recover gains SNS alarm/ok actions (ec2:recover kept); new host_instance_check alarm (StatusCheckFailed_Instance 3 of 3 x 60 s -> ec2:reboot + SNS). tofu only, run on an operator machine; no read is added and nothing on a box reads the file. file:external@0 9a853f2ebe04ad817b318b699a0338fff391bb293251867507c8a470bbf1be13 |
| +infra/modules/region-host/variables.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-console-invite-delivery;basis=tofu on an operator's machine with the operator's AWS credentials (no box unit; no binary embeds the file): main's variables with console_mail_from (validated as one lowercase address) and console_mail_region, both empty by default; no read is added and nothing on a box reads the file;rev3=census-ruling-hunt-account-root-hardening;basis=adds deny_release_key_reads (bool, default true); no read is added and nothing on a box reads the file;rev3=census-ruling-region-ha-p3b;basis=Add default-fixed mode and validated group count, zones, pinned image/release/template, ingress, configuration key and transaction-open refusal. Operator-supplied Terraform values select root boot inputs; no direct box runtime read and no group activation by default.;rev3=census-ruling-region-ha-g2-fixes;basis=Add an empty-default set of additional alert topic ARNs, validating concrete SNS topic syntax and excluding wildcards/subscriptions; operator Terraform input, no box runtime read.;rev3=census-ruling-region-ha-g3-fixes;basis=Add optional alerts_topic_arn with concrete same-region SNS ARN validation and mutual exclusion with alerts_email. The caller owns the existing topic policy and subscriptions; no runtime sink is configured and no new root read is added.;rev3=census-ruling-managed-fleets-2b1;basis=managed fleets 2b-1 Task 5: five variables, managed_fleets_enabled (bool, default false, refused unless mode is fixed), managed_fleets_deployment, managed_fleets_regions (concrete ami/subnet/sg IDs, arm64 types, no ID in two regions), managed_fleet_bucket_prefix (1-24 chars, no reserved prefix, must not cover the deployment, data or staging buckets, disjoint from store_bucket_prefix) and managed_fleet_user_path (literal IAM path, disjoint from store_user_path); store_bucket_prefix and store_user_path gain a validation refusing *, ? or ${ only when managed fleets and object storage are both on; operator Terraform input only; no box runtime read and nothing on a box reads the file;rev3=census-ruling-fixedbox-health-alarms;basis=Add optional health_alerts_topic_arn (concrete same-region SNS ARN validation, empty default); enable_auto_recovery description covers both status alarms. Operator Terraform input; no box runtime read. file:external@0 cc573d8d025df8b036346236815e3f08772b49cadcc504ae7ec2e4bafafffc14 |
| +infra/modules/region-host/tests/health_alarms.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-fixedbox-health-alarms;basis=New mock-provider tofu test file for the status-check alarms; runs only under tofu test on a developer machine, nothing on a box reads it. file:external@0 0c526103bbe8cdb69222da5015cadf7ae3350bc0688abf732222b73480f67550 |
| +@coverage infra/modules/region-host f7bd57559691e86c99aece2ca467dbe53e94d915b70ba54869de6e7caa7ee4f6 |
| +@coverage infra/modules/region-host/tests e7ae8af633fd286bb0ed75f4e7e685a237617221fd6970441141b506a8b5bbfb |