ADR-0030: CI roles read only what their job needs#

  • Status: accepted. Replaces decision 2 of ADR-0019; refines ADR-0006.
  • Date: 2026-11-26

Context#

The plan role carried AWS's ReadOnlyAccess: every read in the account, including every S3 object, log event and IAM entity. Three workflows use it, each planning only the production root: terraform-plan, drift-detection and the plan-only run of terraform-apply. A plan reads its state and refreshes every resource and data source.

Every role that works on the stack could also read the bootstrap and seed state: the plan and deploy roles through a state allow on the whole bucket, the apply role because ADR-0019 denied it everything on those keys except reads. None needs them. The stack takes the bootstrap layer's outputs as variables, site-deploy reads only testz/prod, and bootstrap-account uses the seed's bootstrap role, which reads only bootstrap/. That state holds no secrets, but it maps what every CI role may do. Both were wider than principle 4 asks.

Decision#

  1. The plan role holds no managed policy. An inline policy grants the read verbs (Describe*, Get*, List*, and Budgets' ViewBudget) of the services the stack uses: ACM, Budgets, CloudFront, CloudWatch, KMS, Lambda, Route 53, Route 53 Domains, EventBridge Scheduler and SNS. Three are narrower, because their read verbs reach past configuration: S3 gets named bucket-configuration reads on testz-* buckets (s3:Get* includes GetObject), CloudWatch Logs gets DescribeLogGroups and ListTagsForResource (logs:Get* reads events), and IAM is read only on testz-* roles. Objects are read only under testz/ in the state bucket. aws_iam_role_policy_attachments_exclusive holds its managed policies empty.
  2. The plan, apply and deploy roles are each denied every action, reads included, on bootstrap/ and seed/, and their state allows cover only testz/.
  3. The bootstrap role and the seed do not change. The seed lets the bootstrap role attach or detach ReadOnlyAccess only: detaching is how this change is applied, and attaching grants nothing PutRolePolicy does not.
  4. The apply role's KMS management actions stay on *. Every customer-managed key in the account is a DNSSEC key it must manage, a second signed zone's included, so scoping them protects nothing.
  5. tofu test asserts each of these.

Alternatives considered#

An exact action list, as Access Analyzer would generate. The narrowest policy, and the most brittle: provider releases change which calls a refresh makes (the current one tries s3:ListTagsForResource before GetBucketTagging), and each change would fail every plan. Read verbs of services the stack already uses show only configuration it defines. Kept where read verbs reach data: S3 and Logs.

Keep ReadOnlyAccess and deny the sensitive reads. A deny list against a policy AWS extends with every service launch: the role would gain reads with no change here.

Scope every service to the project's ARNs. Several reads the provider makes (kms:ListAliases, cloudfront:ListCachePolicies) take only *, and the account holds nothing but this project. Applied to IAM and S3, whose account-wide reads describe more than the stack.

Narrow the allows and add no deny. The apply role's bucket statement and the deploy role's site statement match state keys, because a wildcard in an ARN spans /. Only a deny holds whatever allows are added later.

Consequences#

Positive: a pull request's credential reads the stack's configuration and state, not the account's objects, logs or identities, and nothing AWS adds later. No role that works on the stack can read the layer that defines the CI roles' permissions. A managed policy attached by hand to the plan role shows in the next bootstrap-account plan.

Negative: a pull request that adds a resource of a new AWS service fails its plan until a terraform/bootstrap change adding that service is merged and applied by bootstrap-account. Its apply already needed that; now its plan does too. So does a provider release that reads a setting outside the named S3 and Logs actions. A missing read fails loudly, but it stops pull-request plans, drift detection and the plan-only run every apply starts from. The repair is a revert and a bootstrap-account run, whose role this does not touch. Only the plan role's deny can be seen refusing, from a pull request; for the other two, which trust only main, the tests show the same statement.

Neutral: no trust policy changes, no seed run, no cost.

Revisit when#

  • The stack reads another layer's state, or a workflow plans another layer with the plan role.
  • Provider upgrades keep needing S3 or Logs reads not named here.
  • A customer-managed key the apply role need not manage is added to the account: scope its KMS actions to the DNSSEC keys.
  • The seed runs for another reason: drop the bootstrap role's right to attach ReadOnlyAccess.

Built 2026-12-01 from commit 5f3eb2c4b04f9d8367364b6f4598a05a364e2263. This page was generated from the same source that provisions the infrastructure it describes.