region HA P3b T2: review fixes for group readiness and boot scope
Disable apply-time capacity waits and isolate the group queue selection under regional boot parameters. Narrow deployment version reads to the regional bootstrap prefix, reject duplicate ingress addresses, and pin HTTPS sources. Describe group outputs and cover the changes with mock plans and IAM witnesses.
Co-Authored-By: GPT-6 Astra (codex) <noreply@openai.com>
infra/modules/region-host/group.tf+2 −1infra/modules/region-host/group_iam.tf+7 −6infra/modules/region-host/outputs.tf+15 −8infra/modules/region-host/tests/fixed-and-group/main.tf+1 −1infra/modules/region-host/tests/group.tftest.hcl+54 −4infra/modules/region-host/tests/group_iam.tftest.hcl+14 −2infra/modules/region-host/tests/group_isolation.tftest.hcl+5 −1infra/modules/region-host/variables.tf+2 −1scripts/region_group_contract_test.py+11 −2
Intent
<task-notification> <task-id>a9ea154c3e8d02dbb</task-id> <tool-use-id>toolu_0157aYwrDtPAHAZ3umsSdKYG</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/05c816f1-0a2d-43e3-9285-de8352549786/tasks/a9ea154c3e8d02dbb.output</output-file> <status>completed</status> <summary>Agent "Review Task 2 (spec + quality)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Verdict: Needs fixes.** I found no P1 issues, so under the AGENTS.md stopping rule the review stops at this round. The IAM rules, the SSM and KMS scoping, lifecycle completion, the box-roles Deny, the group's own termination queue and the plan gate's narrow role exception all match the brief and spec §12.1/§12.2. Fixed-mode policy text is unchanged byte for byte. I re-ran no suites and made no AWS calls. **P1:** none. **P2** - **P2-1** `infra/modules/region-host/group.tf:206-246`, invariant T1/H5. The group has no `wait_for_capacity_timeout`, so OpenTofu waits its default 10 minutes, while the launch hook allows boxes 900 seconds. A first boot that takes 10 to 15 minutes, and every boot under the current `exit 1` placeholder, makes the apply fail after the group exists. OpenTofu then marks the group for replacement, and the gate refuses the next plan as a size decrease, leaving the operator stuck mid-window. Fix: set the timeout to `"0"` (let the card's readback own readiness) or above 900 seconds, and assert it in `group_shape`. - **P2-2** `group.tf:248-254` against `internal/hostenv/hostenv.go:387-449`, invariant I3/I6/E1. The module writes `/carlos/<dep>/<region>/CARLOS_TERMINATION_QUEUE_URL`. The documented operator seed copies a box's existing host.env into that same path and overwrites what is there, and a fixed box's file holds the fixed queue URL. - Seed after apply: the group's queue choice is silently replaced. IAM then refuses the receive, so group boxes fail rather than steal fixed-box events, and the next plan shows drift. - Seed before apply: the apply fails partway with ParameterAlreadyExists. Fix: stop the seed from writing that key for group regions, or move it under `boot/` and have Task 3 inject it. This may need routing to Task 3 or the seed owner. **P3** - **P3-1** No CI step runs the tofu tests, the Python gate tests or `scripts/region_group_contract_test.py` (CI is Go-only). So the "fixed plan unchanged" and combined-policy checks don't guard against later regressions. (S1/E1) - **P3-2** `group_iam.tf:22-25`: `s3:GetObjectVersion` now covers the whole deployment bucket, which the fixed role never had and no merged box code uses. Limit it to the bootstrap key prefix once Task 3 needs it. (E1) - **P3-3** `variables.tf:331-339`: the per-zone public IPs aren't required to be distinct, and every fixture uses the same IP for both zones, so the per-zone address check is never really tested. (N1/A1) - **P3-4** `tests/group.tftest.hcl:159-166`: the security-group test doesn't pin the three sources allowed on 443. (N1) - **P3-5** `variables.tf:358-367`: `group_transaction_open` is supplied by the caller and defaults to false, so it proves nothing on its own. Carry it as a card item. (T1/H5) - **P3-6** Process and cosmetic: the `invalid_group_inputs` test was never seen failing before the fix, only skipped (the report says so honestly). The new `group_*` outputs have no descriptions. Two things I couldn't confirm from the diff: a real OpenTofu 1.12.5 plan still needs the other session's `after_identity` fix, and the fixed-state equality rests on the implementer's manual harness run. Full review: `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-p3b-build/.superpowers/sdd/2026-11-04-region-ha-p3b-group/task-2-review-r1.md`</result> <usage><subagent_tokens>168808</subagent_tokens><tool_uses>37</tool_uses><duration_ms>393699</duration_ms></usage> </task-notification>
Attributed to this commit: 12.6 g CO₂e (1,530,579 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-p3b-t2, 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/group.tf b/infra/modules/region-host/group.tf| index 3b4ecbe76..d873bcd9d 100644 |
| --- a/infra/modules/region-host/group.tf |
| +++ b/infra/modules/region-host/group.tf |
| @@ -209,6 +209,7 @@ resource "aws_autoscaling_group" "group" { |
| min_size = var.box_count |
| max_size = var.box_count |
| desired_capacity = var.box_count |
| + wait_for_capacity_timeout = "0" |
| vpc_zone_identifier = [for zone in var.group_zones : zone.subnet_id] |
| target_group_arns = values(local.group_ingress.target_group_arns) |
| health_check_type = "ELB" |
| @@ -247,7 +248,7 @@ resource "aws_autoscaling_group" "group" { |
| resource "aws_ssm_parameter" "group_queue" { |
| count = local.group_enabled ? 1 : 0 |
| - name = "${local.group_ssm_path}/CARLOS_TERMINATION_QUEUE_URL" |
| + name = "${local.group_ssm_path}/boot/CARLOS_TERMINATION_QUEUE_URL" |
| type = "String" |
| value = aws_sqs_queue.terminations.id |
| tags = local.group_tags |
diff --git a/infra/modules/region-host/group_iam.tf b/infra/modules/region-host/group_iam.tf| index c796f2049..fd991c255 100644 |
| --- a/infra/modules/region-host/group_iam.tf |
| +++ b/infra/modules/region-host/group_iam.tf |
| @@ -1,9 +1,10 @@ |
| locals { |
| - group_ssm_path = local.group_enabled ? "/carlos/${var.group_config.deployment}/${var.group_config.region}" : "" |
| - group_regional_arn = local.group_enabled ? "arn:${data.aws_partition.current[0].partition}:ssm:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:parameter${local.group_ssm_path}" : "" |
| - group_shared_arn = local.group_enabled ? "arn:${data.aws_partition.current[0].partition}:ssm:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:parameter/carlos/${var.group_config.deployment}/shared" : "" |
| - group_parameter_arns = [local.group_regional_arn, "${local.group_regional_arn}/*", local.group_shared_arn, "${local.group_shared_arn}/*"] |
| - group_parameter_actions = ["ssm:GetParameter", "ssm:GetParameters", "ssm:GetParameterHistory", "ssm:GetParametersByPath"] |
| + group_ssm_path = local.group_enabled ? "/carlos/${var.group_config.deployment}/${var.group_config.region}" : "" |
| + group_regional_arn = local.group_enabled ? "arn:${data.aws_partition.current[0].partition}:ssm:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:parameter${local.group_ssm_path}" : "" |
| + group_shared_arn = local.group_enabled ? "arn:${data.aws_partition.current[0].partition}:ssm:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:parameter/carlos/${var.group_config.deployment}/shared" : "" |
| + group_parameter_arns = [local.group_regional_arn, "${local.group_regional_arn}/*", local.group_shared_arn, "${local.group_shared_arn}/*"] |
| + group_parameter_actions = ["ssm:GetParameter", "ssm:GetParameters", "ssm:GetParameterHistory", "ssm:GetParametersByPath"] |
| + group_bootstrap_object_prefix = local.group_enabled ? "bootstrap/${var.group_config.deployment}/${var.group_config.region}/" : "" |
| # Existing move consumers: laneProbe (moves/_lane/), retireOwnMoveState |
| # (move-snapshots/), and placeBuildState / generation selection (instances/). |
| # Version access stays in this region's data bucket, never sibling buckets. |
| @@ -22,7 +23,7 @@ locals { |
| { |
| Effect = "Allow" |
| Action = ["s3:GetObjectVersion"] |
| - Resource = ["${var.deployment_bucket_arn}/*", "${var.data_bucket_arn}/*"] |
| + Resource = ["${var.deployment_bucket_arn}/${local.group_bootstrap_object_prefix}*", "${var.data_bucket_arn}/*"] |
| }, |
| { |
| Sid = "RegionalMoveVersions" |
diff --git a/infra/modules/region-host/outputs.tf b/infra/modules/region-host/outputs.tf| index 3dbb05578..a59fd62cc 100644 |
| --- a/infra/modules/region-host/outputs.tf |
| +++ b/infra/modules/region-host/outputs.tf |
| @@ -44,24 +44,31 @@ output "termination_queue_url" { |
| } |
| output "group_name" { |
| - value = var.mode == "group" ? aws_autoscaling_group.group[0].name : null |
| + description = "Name of the Auto Scaling group. Null in fixed mode." |
| + value = var.mode == "group" ? aws_autoscaling_group.group[0].name : null |
| } |
| output "group_arn" { |
| - value = var.mode == "group" ? aws_autoscaling_group.group[0].arn : null |
| + description = "ARN of the Auto Scaling group. Null in fixed mode." |
| + value = var.mode == "group" ? aws_autoscaling_group.group[0].arn : null |
| } |
| output "group_launch_template_id" { |
| - value = var.mode == "group" ? aws_launch_template.group[0].id : null |
| + description = "ID of the group launch template. Null in fixed mode." |
| + value = var.mode == "group" ? aws_launch_template.group[0].id : null |
| } |
| output "group_launch_template_version" { |
| - value = var.mode == "group" ? var.group_launch_template_version : null |
| + description = "Pinned launch template version used by the group. Null in fixed mode." |
| + value = var.mode == "group" ? var.group_launch_template_version : null |
| } |
| output "group_ingress" { |
| - value = local.group_ingress |
| + description = "NLB, security group, target groups and public IPv4 addresses used by the group. Null in fixed mode." |
| + value = local.group_ingress |
| } |
| output "group_boot_parameters" { |
| + description = "SSM paths for the bootstrap object, hash, ingress and group termination queue. Null in fixed mode." |
| value = var.mode == "group" ? { |
| - bootstrap_object = "${local.group_ssm_path}/boot/bootstrap-object" |
| - bootstrap_sha256 = "${local.group_ssm_path}/boot/bootstrap-sha256" |
| - ingress = "${local.group_ssm_path}/boot/ingress" |
| + bootstrap_object = "${local.group_ssm_path}/boot/bootstrap-object" |
| + bootstrap_sha256 = "${local.group_ssm_path}/boot/bootstrap-sha256" |
| + ingress = "${local.group_ssm_path}/boot/ingress" |
| + termination_queue_url = aws_ssm_parameter.group_queue[0].name |
| } : null |
| } |
diff --git a/infra/modules/region-host/tests/fixed-and-group/main.tf b/infra/modules/region-host/tests/fixed-and-group/main.tf| index 5aff0379c..63d80af07 100644 |
| --- a/infra/modules/region-host/tests/fixed-and-group/main.tf |
| +++ b/infra/modules/region-host/tests/fixed-and-group/main.tf |
| @@ -32,7 +32,7 @@ locals { |
| "80" = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/test-80/1234" |
| "443" = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/test-443/1234" |
| } |
| - public_ips = { eu-west-1a = "198.51.100.10", eu-west-1b = "198.51.100.10" } |
| + public_ips = { eu-west-1a = "198.51.100.10", eu-west-1b = "198.51.100.11" } |
| } |
| } |
| } |
diff --git a/infra/modules/region-host/tests/group.tftest.hcl b/infra/modules/region-host/tests/group.tftest.hcl| index 36128bc96..bd949ce39 100644 |
| --- a/infra/modules/region-host/tests/group.tftest.hcl |
| +++ b/infra/modules/region-host/tests/group.tftest.hcl |
| @@ -50,9 +50,13 @@ override_data { |
| values = { vpc_id = "vpc-0123456789abcdef0", port = 443, protocol = "TCP", target_type = "instance", load_balancer_arns = ["arn:aws:elasticloadbalancing:eu-west-1:123456789012:loadbalancer/net/test/1234"], preserve_client_ip = "true" } |
| } |
| override_data { |
| - target = data.aws_eip.group |
| + target = data.aws_eip.group["eu-west-1a"] |
| values = { public_ip = "198.51.100.10" } |
| } |
| +override_data { |
| + target = data.aws_eip.group["eu-west-1b"] |
| + values = { public_ip = "198.51.100.11" } |
| +} |
| override_resource { |
| target = aws_sqs_queue.terminations |
| values = { arn = "arn:aws:sqs:eu-west-1:123456789012:carlos-dev-ie-group-terminations", id = "https://sqs.eu-west-1.amazonaws.com/123456789012/carlos-dev-ie-group-terminations" } |
| @@ -98,10 +102,43 @@ variables { |
| "80" = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/test-80/1234" |
| "443" = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/test-443/1234" |
| } |
| - public_ips = { eu-west-1a = "198.51.100.10", eu-west-1b = "198.51.100.10" } |
| + public_ips = { eu-west-1a = "198.51.100.10", eu-west-1b = "198.51.100.11" } |
| } |
| } |
| +run "invalid_duplicate_public_ipv4" { |
| + command = plan |
| + variables { |
| + group_ingress = { |
| + nlb_arn = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:loadbalancer/net/test/1234" |
| + nlb_security_group_id = "sg-0123456789abcdef0" |
| + target_group_arns = { |
| + "80" = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/test-80/1234" |
| + "443" = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/test-443/1234" |
| + } |
| + public_ips = { eu-west-1a = "198.51.100.10", eu-west-1b = "198.51.100.10" } |
| + } |
| + } |
| + override_data { |
| + target = data.aws_eip.group["eu-west-1b"] |
| + values = { public_ip = "198.51.100.10" } |
| + } |
| + expect_failures = [var.group_ingress] |
| +} |
| + |
| +run "wrong_zone_public_ipv4" { |
| + command = plan |
| + override_data { |
| + target = data.aws_eip.group["eu-west-1a"] |
| + values = { public_ip = "198.51.100.11" } |
| + } |
| + override_data { |
| + target = data.aws_eip.group["eu-west-1b"] |
| + values = { public_ip = "198.51.100.10" } |
| + } |
| + expect_failures = [aws_security_group.group] |
| +} |
| + |
| run "group_shape" { |
| command = plan |
| assert { |
| @@ -109,6 +146,7 @@ run "group_shape" { |
| aws_autoscaling_group.group[0].min_size == 2 && |
| aws_autoscaling_group.group[0].max_size == 2 && |
| aws_autoscaling_group.group[0].desired_capacity == 2 && |
| + aws_autoscaling_group.group[0].wait_for_capacity_timeout == "0" && |
| aws_autoscaling_group.group[0].enabled_metrics == toset(["GroupInServiceInstances", "GroupDesiredCapacity"]) && |
| aws_autoscaling_group.group[0].metrics_granularity == "1Minute" && |
| aws_autoscaling_group.group[0].health_check_type == "ELB" && |
| @@ -151,7 +189,8 @@ run "group_shape" { |
| aws_cloudwatch_event_target.terminations.arn == aws_sqs_queue.terminations.arn && |
| aws_cloudwatch_event_target.terminations.rule == aws_cloudwatch_event_rule.terminations.name && |
| jsondecode(aws_cloudwatch_event_rule.terminations.event_pattern).detail.state == ["terminated"] && |
| - aws_ssm_parameter.group_queue[0].name == "/carlos/dev/ie/CARLOS_TERMINATION_QUEUE_URL" && |
| + aws_ssm_parameter.group_queue[0].name == "/carlos/dev/ie/boot/CARLOS_TERMINATION_QUEUE_URL" && |
| + output.group_boot_parameters.termination_queue_url == aws_ssm_parameter.group_queue[0].name && |
| nonsensitive(aws_ssm_parameter.group_queue[0].value) == aws_sqs_queue.terminations.id |
| ) |
| error_message = "the group must own its termination queue and regional queue selection" |
| @@ -162,8 +201,19 @@ run "group_shape" { |
| rule.protocol == "tcp" && rule.to_port == rule.from_port && |
| length(rule.ipv6_cidr_blocks) == 0 && contains([80, 443], rule.from_port) && |
| (rule.from_port != 80 || toset(rule.security_groups) == toset([var.group_ingress.nlb_security_group_id])) |
| + ]) && toset([ |
| + for rule in aws_security_group.group[0].ingress : jsonencode({ |
| + cidr_blocks = sort(tolist(coalesce(rule.cidr_blocks, []))) |
| + security_groups = sort(tolist(coalesce(rule.security_groups, []))) |
| + prefix_list_ids = sort(tolist(coalesce(rule.prefix_list_ids, []))) |
| + self = rule.self == true |
| + }) if rule.from_port == 443 |
| + ]) == toset([ |
| + jsonencode({ cidr_blocks = [], security_groups = [var.group_ingress.nlb_security_group_id], prefix_list_ids = [], self = false }), |
| + jsonencode({ cidr_blocks = ["0.0.0.0/0"], security_groups = [], prefix_list_ids = [], self = false }), |
| + jsonencode({ cidr_blocks = ["10.0.0.0/16"], security_groups = [], prefix_list_ids = [], self = false }), |
| ]) |
| - error_message = "group HTTP must require the NLB and no SSH or IPv6 ingress is allowed" |
| + error_message = "group HTTP must require the NLB, HTTPS must retain its three exact sources, and no SSH or IPv6 ingress is allowed" |
| } |
| } |
| run "invalid_group_inputs" { |
diff --git a/infra/modules/region-host/tests/group_iam.tftest.hcl b/infra/modules/region-host/tests/group_iam.tftest.hcl| index 0b5529fc8..dcedf6161 100644 |
| --- a/infra/modules/region-host/tests/group_iam.tftest.hcl |
| +++ b/infra/modules/region-host/tests/group_iam.tftest.hcl |
| @@ -50,9 +50,13 @@ override_data { |
| values = { vpc_id = "vpc-0123456789abcdef0", port = 443, protocol = "TCP", target_type = "instance", load_balancer_arns = ["arn:aws:elasticloadbalancing:eu-west-1:123456789012:loadbalancer/net/test/1234"], preserve_client_ip = "true" } |
| } |
| override_data { |
| - target = data.aws_eip.group |
| + target = data.aws_eip.group["eu-west-1a"] |
| values = { public_ip = "198.51.100.10" } |
| } |
| +override_data { |
| + target = data.aws_eip.group["eu-west-1b"] |
| + values = { public_ip = "198.51.100.11" } |
| +} |
| override_resource { |
| target = aws_sqs_queue.terminations |
| values = { arn = "arn:aws:sqs:eu-west-1:123456789012:carlos-dev-ie-group-terminations", id = "https://sqs.eu-west-1.amazonaws.com/123456789012/carlos-dev-ie-group-terminations" } |
| @@ -98,12 +102,19 @@ variables { |
| "80" = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/test-80/1234" |
| "443" = "arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/test-443/1234" |
| } |
| - public_ips = { eu-west-1a = "198.51.100.10", eu-west-1b = "198.51.100.10" } |
| + public_ips = { eu-west-1a = "198.51.100.10", eu-west-1b = "198.51.100.11" } |
| } |
| } |
| run "group_iam_exact_scope" { |
| command = plan |
| + assert { |
| + condition = toset(flatten([ |
| + for statement in jsondecode(aws_iam_role_policy.host_buckets.policy).Statement : |
| + statement.Resource if statement.Effect == "Allow" && contains(statement.Action, "s3:GetObjectVersion") |
| + ])) == toset(["${var.deployment_bucket_arn}/bootstrap/dev/ie/*", "${var.data_bucket_arn}/*"]) |
| + error_message = "group version reads must stay in the regional bootstrap prefix and data bucket" |
| + } |
| assert { |
| condition = ( |
| toset(jsondecode(aws_iam_role_policy.group[0].policy).Statement[0].Resource) == toset([ |
| @@ -130,6 +141,7 @@ run "group_iam_exact_scope" { |
| } |
| assert { |
| condition = ( |
| + aws_ssm_parameter.group_queue[0].name == "/carlos/dev/ie/boot/CARLOS_TERMINATION_QUEUE_URL" && |
| aws_iam_role_policy_attachment.host_ssm.policy_arn == "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore" && |
| length(aws_iam_role_policy.host_release_key_deny) == 1 && |
| length(aws_iam_role_policy.host_costexplorer) == 0 && |
diff --git a/infra/modules/region-host/tests/group_isolation.tftest.hcl b/infra/modules/region-host/tests/group_isolation.tftest.hcl| index 539400bd5..70e2626de 100644 |
| --- a/infra/modules/region-host/tests/group_isolation.tftest.hcl |
| +++ b/infra/modules/region-host/tests/group_isolation.tftest.hcl |
| @@ -55,9 +55,13 @@ override_data { |
| values = { vpc_id = "vpc-0123456789abcdef0", port = 443, protocol = "TCP", target_type = "instance", load_balancer_arns = ["arn:aws:elasticloadbalancing:eu-west-1:123456789012:loadbalancer/net/test/1234"], preserve_client_ip = "true" } |
| } |
| override_data { |
| - target = module.group.data.aws_eip.group |
| + target = module.group.data.aws_eip.group["eu-west-1a"] |
| values = { public_ip = "198.51.100.10" } |
| } |
| +override_data { |
| + target = module.group.data.aws_eip.group["eu-west-1b"] |
| + values = { public_ip = "198.51.100.11" } |
| +} |
| override_resource { |
| target = module.group.aws_sqs_queue.terminations |
| values = { arn = "arn:aws:sqs:eu-west-1:123456789012:carlos-dev-ie-group-terminations", id = "https://sqs.eu-west-1.amazonaws.com/123456789012/carlos-dev-ie-group-terminations" } |
diff --git a/infra/modules/region-host/variables.tf b/infra/modules/region-host/variables.tf| index c55985cfb..c7571f284 100644 |
| --- a/infra/modules/region-host/variables.tf |
| +++ b/infra/modules/region-host/variables.tf |
| @@ -336,12 +336,13 @@ variable "group_ingress" { |
| toset(keys(var.group_ingress.target_group_arns)) == toset(["80", "443"]) && |
| length(distinct(values(var.group_ingress.target_group_arns))) == 2 && |
| toset(keys(var.group_ingress.public_ips)) == toset(keys(var.group_zones)) && |
| + length(distinct(values(var.group_ingress.public_ips))) == length(var.group_zones) && |
| alltrue([for ip in var.group_ingress.public_ips : can(cidrnetmask("${ip}/32"))]) && |
| can(regex("^sg-[0-9a-f]{17}$", var.group_ingress.nlb_security_group_id)) && |
| can(regex("^arn:${data.aws_partition.current[0].partition}:elasticloadbalancing:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:loadbalancer/net/[A-Za-z0-9/-]+$", var.group_ingress.nlb_arn)) && |
| alltrue([for arn in var.group_ingress.target_group_arns : can(regex("^arn:${data.aws_partition.current[0].partition}:elasticloadbalancing:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:targetgroup/[A-Za-z0-9/-]+$", arn))]) |
| ) |
| - error_message = "group_ingress must name this account and region's NLB, both target groups, its security group and one public IPv4 per group zone" |
| + error_message = "group_ingress must name this account and region's NLB, both target groups, its security group and one distinct public IPv4 per group zone" |
| } |
| } |
diff --git a/scripts/region_group_contract_test.py b/scripts/region_group_contract_test.py| index d1b10a8e5..ee567697d 100644 |
| --- a/scripts/region_group_contract_test.py |
| +++ b/scripts/region_group_contract_test.py |
| @@ -109,7 +109,8 @@ def audit_group(plan, dns): |
| (['autoscaling:CompleteLifecycleAction'], ['arn:aws:autoscaling:eu-west-1:123456789012:autoScalingGroup:*:autoScalingGroupName/carlos-dev-ie-group']), |
| (['ec2:DescribeInstances', 'cloudwatch:PutMetricData'], ['*']), |
| (['sqs:ReceiveMessage', 'sqs:DeleteMessage', 'sqs:GetQueueAttributes'], ['arn:aws:sqs:eu-west-1:123456789012:carlos-dev-ie-group-terminations']), |
| - (['s3:GetObject', 's3:PutObject', 's3:DeleteObject', 's3:GetObjectVersion'], ['arn:aws:s3:::carlos-dev-platform/*', 'arn:aws:s3:::carlos-dev-ie/*']), |
| + (['s3:GetObject', 's3:PutObject', 's3:DeleteObject'], ['arn:aws:s3:::carlos-dev-platform/*', 'arn:aws:s3:::carlos-dev-ie/*']), |
| + (['s3:GetObjectVersion'], ['arn:aws:s3:::carlos-dev-platform/bootstrap/dev/ie/*', 'arn:aws:s3:::carlos-dev-ie/*']), |
| (['s3:ListBucket', 's3:GetBucketLocation'], ['arn:aws:s3:::carlos-dev-platform', 'arn:aws:s3:::carlos-dev-ie']), |
| (['s3:DeleteObjectVersion'], ['arn:aws:s3:::carlos-dev-ie/' + p for p in ['instances/*', 'moves/*', 'move-snapshots/*']]), |
| (['s3:ListBucketVersions'], ['arn:aws:s3:::carlos-dev-ie']), |
| @@ -129,7 +130,7 @@ def audit_group(plan, dns): |
| assert not allowed(statements, 'cloudwatch:PutMetricData', '*', {'cloudwatch:namespace': 'Other'}) |
| parameter = 'arn:aws:ssm:eu-west-1:123456789012:parameter' |
| for prefix in ['/carlos/dev/ie', '/carlos/dev/shared']: |
| - for suffix in ['', '/ENV', '/boot/bootstrap-object', '/boot/bootstrap-sha256', '/boot/ingress']: |
| + for suffix in ['', '/ENV', '/boot/bootstrap-object', '/boot/bootstrap-sha256', '/boot/ingress', '/boot/CARLOS_TERMINATION_QUEUE_URL']: |
| for action in ['ssm:GetParameter', 'ssm:GetParameters', 'ssm:GetParameterHistory', 'ssm:GetParametersByPath']: |
| assert allowed(statements, action, parameter + prefix + suffix) |
| for path in ['', '/', '/carlos', '/carlos/', '/carlos/dev', '/carlos/dev/', |
| @@ -169,7 +170,13 @@ def audit_group(plan, dns): |
| assert not allowed(statements, action, bucket + '/' + path) |
| for path in ['control/edges/i-test.json', 'control/identities/i-test.json', 'control/terminations/i-test.json']: |
| assert allowed(statements, 's3:PutObject', bucket + '/' + path) |
| + assert allowed(statements, 's3:GetObjectVersion', bucket + '/bootstrap/dev/ie/carlos') |
| + for path in ['control/box-roles/i-test.json', 'control/edges/i-test.json', |
| + 'bootstrap/dev/fr/carlos', 'bootstrap/other/ie/carlos', |
| + 'bootstrap/dev/ie-other/carlos']: |
| + assert not allowed(statements, 's3:GetObjectVersion', bucket + '/' + path) |
| data = 'arn:aws:s3:::carlos-dev-ie' |
| + assert allowed(statements, 's3:GetObjectVersion', data + '/instances/shop/db') |
| assert allowed(statements, 's3:DeleteObject', data + '/instances/shop/lock.json') |
| for path in ['moves/_lane/probe', 'move-snapshots/shop/op/db', 'instances/shop/build-state.json']: |
| assert allowed(statements, 's3:DeleteObjectVersion', data + '/' + path) |
| @@ -180,6 +187,8 @@ def audit_group(plan, dns): |
| assert not allowed(statements, 's3:DeleteObjectVersion', data + '/' + path) |
| assert not allowed(statements, 's3:ListBucketVersions', data) |
| queue = resources['aws_sqs_queue.terminations'] |
| + assert resources['aws_ssm_parameter.group_queue[0]']['name'] == '/carlos/dev/ie/boot/CARLOS_TERMINATION_QUEUE_URL' |
| + assert resources['aws_ssm_parameter.group_queue[0]']['value'] == queue['id'] |
| arn = 'arn:aws:sqs:eu-west-1:123456789012:carlos-dev-ie-group-terminations' |
| assert queue['arn'] == arn |
| assert queue['id'] == 'https://sqs.eu-west-1.amazonaws.com/123456789012/carlos-dev-ie-group-terminations' |