Fix group operator policy and test hygiene for R7
Allow deployment edges reads and caller-owned session data channels. Use BoolIfExists for document checks while retaining the approved document. Clarify capacity authority and cover the missing-TMPDIR test fallback.
4 files changed,
+45
−6
infra/modules/region-host/README.md+4 −1infra/modules/region-host/group_operator.tf+20 −3infra/modules/region-host/tests/group_operator.tftest.hcl+13 −1scripts/region_group_ssm_boot_test.py+8 −1
Intent
Human
<task-notification> <task-id>bed6w9s10</task-id> <tool-use-id>toolu_01XDJPMC7GrfkUgK9utd6UK2</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/e47280e8-3e59-4dc1-95d2-11de7237d34c/tasks/bed6w9s10.output</output-file> <status>completed</status> <summary>Background command ".superpowers/sdd/2026-11-04-region-ha-p3b-group/run-astra.sh b2" completed (exit code 0)</summary> </task-notification>
diff --git a/infra/modules/region-host/README.md b/infra/modules/region-host/README.md| index e5926a395..a3dcddd40 100644 |
| --- a/infra/modules/region-host/README.md |
| +++ b/infra/modules/region-host/README.md |
| @@ -156,7 +156,10 @@ document; its default is the regional AWS-managed |
| account and region. The policy grants group-scoped maintenance actions and |
| Session Manager access to this group's tagged instances. The operator tool |
| must still enforce the instance, hook, transaction and `CONTINUE` result. |
| -Termination requires separate fault authority. |
| +The policy grants no direct termination action, but `UpdateAutoScalingGroup` |
| +can still lower capacity or set lifetime limits. Only the operator command |
| +may use it, and only in the N-HA14 shape: minimum N-1 during Standby, |
| +restored to N after return. |
| Do not associate `AWS-UpdateSSMAgent`, patch baselines, or automatic patch or |
| reboot jobs with group members. This module creates no State Manager |
diff --git a/infra/modules/region-host/group_operator.tf b/infra/modules/region-host/group_operator.tf| index c55d48004..f757a7d51 100644 |
| --- a/infra/modules/region-host/group_operator.tf |
| +++ b/infra/modules/region-host/group_operator.tf |
| @@ -53,14 +53,17 @@ output "group_operator_policy_json" { |
| Resource = "arn:${data.aws_partition.current[0].partition}:ec2:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:instance/*" |
| Condition = { |
| StringEquals = { "aws:ResourceTag/aws:autoscaling:groupName" = var.name } |
| - # Require document authorization even when the caller omits its name. |
| - # https://docs.aws.amazon.com/service-authorization/latest/reference/list_ssm.html |
| - Bool = { "ssm:SessionDocumentAccessCheck" = "true" } |
| + # Use AWS's documented BoolIfExists form for document access checks. |
| + # https://aws.amazon.com/blogs/security/how-to-enable-secure-seamless-single-sign-on-to-amazon-ec2-windows-instances-with-aws-sso/ |
| + BoolIfExists = { "ssm:SessionDocumentAccessCheck" = "true" } |
| } |
| }, |
| { |
| # Document authorization is separate: AWS-owned documents do not carry |
| # the instance's group tag. Both resources must authorize StartSession. |
| + # An omitted name selects SSM-SessionManagerRunShell. That document has |
| + # no Allow here, so the document access check still refuses the default |
| + # shell unless the deployment explicitly approves it as its document. |
| Sid = "ApprovedSessionDocument" |
| Effect = "Allow" |
| Action = ["ssm:StartSession"] |
| @@ -76,6 +79,20 @@ output "group_operator_policy_json" { |
| # https://aws.amazon.com/blogs/mt/configuring-aws-systems-manager-session-manager-support-federated-users-using-session-tags/ |
| Condition = { StringEquals = { "ssm:resourceTag/aws:ssmmessages:session-id" = "$${aws:userid}" } } |
| }, |
| + { |
| + Sid = "ReadMemberEdges" |
| + Effect = "Allow" |
| + Action = ["s3:GetObject"] |
| + Resource = "${var.deployment_bucket_arn}/control/edges/*" |
| + }, |
| + { |
| + # AWS's end-user policy scopes the channel to the caller's session ARNs. |
| + # https://docs.aws.amazon.com/systems-manager/latest/userguide/getting-started-restrict-access-quickstart.html |
| + Sid = "OwnSessionDataChannel" |
| + Effect = "Allow" |
| + Action = ["ssmmessages:OpenDataChannel"] |
| + Resource = "${local.group_operator_ssm_arn}${data.aws_caller_identity.current.account_id}:session/$${aws:userid}-*" |
| + }, |
| ] |
| }) |
| precondition { |
diff --git a/infra/modules/region-host/tests/group_operator.tftest.hcl b/infra/modules/region-host/tests/group_operator.tftest.hcl| index c95b4d1a2..4ff6094c0 100644 |
| --- a/infra/modules/region-host/tests/group_operator.tftest.hcl |
| +++ b/infra/modules/region-host/tests/group_operator.tftest.hcl |
| @@ -145,7 +145,7 @@ run "operator_policy" { |
| Resource = "arn:aws:ec2:eu-west-1:123456789012:instance/*" |
| Condition = { |
| StringEquals = { "aws:ResourceTag/aws:autoscaling:groupName" = "carlos-dev-ie-group" } |
| - Bool = { "ssm:SessionDocumentAccessCheck" = "true" } |
| + BoolIfExists = { "ssm:SessionDocumentAccessCheck" = "true" } |
| } |
| }, |
| { |
| @@ -161,6 +161,18 @@ run "operator_policy" { |
| Resource = "arn:aws:ssm:eu-west-1:123456789012:session/*" |
| Condition = { StringEquals = { "ssm:resourceTag/aws:ssmmessages:session-id" = "$${aws:userid}" } } |
| }, |
| + { |
| + Sid = "ReadMemberEdges" |
| + Effect = "Allow" |
| + Action = ["s3:GetObject"] |
| + Resource = "${var.deployment_bucket_arn}/control/edges/*" |
| + }, |
| + { |
| + Sid = "OwnSessionDataChannel" |
| + Effect = "Allow" |
| + Action = ["ssmmessages:OpenDataChannel"] |
| + Resource = "arn:aws:ssm:eu-west-1:123456789012:session/$${aws:userid}-*" |
| + }, |
| ] |
| })) |
| error_message = "the operator policy must contain only the exact group writes, describes, tagged document-checked sessions and caller-owned session controls" |
diff --git a/scripts/region_group_ssm_boot_test.py b/scripts/region_group_ssm_boot_test.py| index 8766c9cb1..2a3bfe959 100644 |
| --- a/scripts/region_group_ssm_boot_test.py |
| +++ b/scripts/region_group_ssm_boot_test.py |
| @@ -3,6 +3,7 @@ import subprocess |
| import tempfile |
| import unittest |
| from pathlib import Path |
| +from unittest import mock |
| TEMPLATE = Path(__file__).resolve().parent.parent / 'infra/modules/region-host/group-init.sh.tftpl' |
| STAGING = '/var/lib/carlos-group-boot' |
| @@ -30,10 +31,16 @@ class SSMBootTests(unittest.TestCase): |
| self.assertIn('https://s3.$AWS_REGION.amazonaws.com/amazon-ssm-$AWS_REGION/latest/debian_arm64/amazon-ssm-agent.deb', source) |
| self.assertNotIn('AWS-UpdateSSMAgent', source) |
| + def test_install_without_tmpdir(self): |
| + with tempfile.TemporaryDirectory(dir=os.environ.get('TMPDIR')) as fallback: |
| + with mock.patch.dict(os.environ), mock.patch.object(tempfile, 'tempdir', fallback): |
| + os.environ.pop('TMPDIR', None) |
| + self.test_install_failures_stop_boot() |
| + |
| def test_install_failures_stop_boot(self): |
| source = TEMPLATE.read_text() |
| block = source.split('# install maintenance channel\n', 1)[1].split('# configure chrony', 1)[0] |
| - with tempfile.TemporaryDirectory(dir=os.environ['TMPDIR']) as tmp: |
| + with tempfile.TemporaryDirectory(dir=os.environ.get('TMPDIR')) as tmp: |
| root = Path(tmp) |
| for command in ('curl', 'dpkg', 'systemctl'): |
| stub = root / command |