From a5a12e510ee8f0a74ccf22366d511d5e4dd8ea90 Mon Sep 17 00:00:00 2001 From: Matej Lauko Date: Fri, 20 Nov 2026 17:25:52 +0100 Subject: [PATCH] Let the AI SRE role read the account's name Add account:GetAccountInformation to the restricted role's InvestigationReads statement, next to iam:ListAccountAliases and account:ListRegions, so Better Stack can name an integration after its AWS account. Most accounts have no sign-in alias, so the alias alone leaves only the account ID. AllowConfigurationValues=true needs no change: AWS's ReadOnlyAccess already grants the action, and no deny policy names an account: action. --- cloudformation/ai-sre/README.md | 2 +- cloudformation/ai-sre/better-stack-ai-sre.yaml | 3 ++- cloudformation/ai-sre/restricted-reads.txt | 1 + cloudformation/ai-sre/test/simulate_policy.py | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cloudformation/ai-sre/README.md b/cloudformation/ai-sre/README.md index 5ade204..98be0fc 100644 --- a/cloudformation/ai-sre/README.md +++ b/cloudformation/ai-sre/README.md @@ -58,7 +58,7 @@ The role has no `ReadOnlyAccess`. It reads exactly this list, minus the configur - Load balancers, API Gateway configuration and Route 53 zones - SQS, SNS, Kinesis and Firehose metadata; Step Functions and EventBridge - CloudTrail trails and event history (`LookupEvents`), AWS Health events, X-Ray traces -- CloudFormation stacks and their resources' status, not their `Metadata`, Application Auto Scaling, the account alias and enabled regions +- CloudFormation stacks and their resources' status, not their `Metadata`, Application Auto Scaling, the account alias, the account name (`account:GetAccountInformation`) and enabled regions - Its own role and policies, and the stack's two deny policies (`iam:GetRole` and the role policy reads on its own ARN, `iam:GetPolicy` and `iam:GetPolicyVersion` on the two policies' ARNs, nothing else), to tell which release it runs and what it allows - `signin:CreateOAuth2Token` for AWS's MCP Server, which Better Stack calls with the role's session - `kms:Decrypt` through CloudWatch Logs only, for log groups encrypted with your key diff --git a/cloudformation/ai-sre/better-stack-ai-sre.yaml b/cloudformation/ai-sre/better-stack-ai-sre.yaml index c62d1d0..2ce30cd 100644 --- a/cloudformation/ai-sre/better-stack-ai-sre.yaml +++ b/cloudformation/ai-sre/better-stack-ai-sre.yaml @@ -287,7 +287,7 @@ Resources: - health:Describe* Resource: '*' # Logs Insights, recent API activity, traces, deployment history from stack events, scaling, the - # account alias and the enabled regions. + # account alias, the account name and the enabled regions. - Sid: InvestigationReads Effect: Allow Action: @@ -301,6 +301,7 @@ Resources: - application-autoscaling:Describe* - iam:ListAccountAliases - account:ListRegions + - account:GetAccountInformation Resource: '*' - !Ref 'AWS::NoValue' - !If diff --git a/cloudformation/ai-sre/restricted-reads.txt b/cloudformation/ai-sre/restricted-reads.txt index 5668c40..3cdd283 100644 --- a/cloudformation/ai-sre/restricted-reads.txt +++ b/cloudformation/ai-sre/restricted-reads.txt @@ -1,3 +1,4 @@ +account:GetAccountInformation account:ListRegions apigateway:GET denied on some resources application-autoscaling:DescribeScalableTargets diff --git a/cloudformation/ai-sre/test/simulate_policy.py b/cloudformation/ai-sre/test/simulate_policy.py index c2d6a93..efd22d9 100644 --- a/cloudformation/ai-sre/test/simulate_policy.py +++ b/cloudformation/ai-sre/test/simulate_policy.py @@ -112,6 +112,7 @@ def both(decision): ("application-autoscaling:DescribeScalableTargets", ANY, (), *both(ALLOW)), ("iam:ListAccountAliases", ANY, (), *both(ALLOW)), ("account:ListRegions", ANY, (), *both(ALLOW)), + ("account:GetAccountInformation", ANY, (), *both(ALLOW)), # The role's own description and policies; other roles' only through ReadOnlyAccess. ("iam:GetRole", SELF, (), *both(ALLOW)), ("iam:ListRolePolicies", SELF, (), *both(ALLOW)),