IAM designPolicies and guardrails that scale with the number of repositories
Design rule: nothing in IAM policies, SCPs, RCPs, key policies or platform configuration grows with the number of repositories. A repository costs a fixed set of roles and resources. Once an account's quotas are reached, you add another account (a cell), not a bigger policy.
Phase 1 implemented · 2026-11-21Status (2026-11-22): phases 1 and 2 are implemented and tested against real AWS and GitHub (details on Tests & samples).
- Boundary: 6,042 of IAM's 6,144 characters, whatever the number of repositories, leaving about 100 characters. A larger permission must replace or merge existing entries.
just iam-sim: 92 of 92 simulations pass, and Access Analyzer finds no errors in the five documents.- Real GitHub OIDC: 37 of 37 checks through both deploy paths, and 20 of 20 through the tagger alone.
- Deploy as the repository: the test repository applied and destroyed its own runners through the tagger and the shared deploy role, including the image build and the dashboard.
- Real jobs: jobs and drills ran on MicroVMs; the broker's registry lookup with a real GitHub App worked.
- Guardrails live: in a member account, all 18 SCP checks pass. The RCP checks wait until that new account's services are active.
TodayWhat grows with each repository
| Item | Limit it hits | Replaced by |
|---|---|---|
| One managed boundary policy per repository | 1,500 customer managed policies per account by default (10,000 at most) | One generic boundary per account |
Boundary size grows with job_parameter_paths, job_secret_prefixes and additional_job_actions | 6,144 characters per managed policy; already at 5,768 with defaults | Fixed-size policy built with policy variables. Extra secrets and parameters are shared by tagging them (opt-in). Extra job actions are set once per account. |
boundaries map in /<prefix>/platform/config | 4 KB for a Standard SSM parameter (about 40 repositories) | One boundary_arn value |
ALLOWED_REPOSITORIES in the broker's environment | 4 KB of Lambda environment variables | Registry: one SSM parameter per repository, /<prefix>/registry/<id> |
check "repository_onboarded" and boundaries[repo] in repo-runner and runner-image | Grows with the map above | Reading the repository's registry parameter, which fails if the repository isn't onboarded |
A per-repository deploy role and an apply of bootstrap for every onboarding | Role quota, and a platform-team change for each repository | Phase 2: one shared deploy role, reached through a tagging broker (the tagger) that sets session tags. Onboarding then only writes a registry entry. |
| Reserved concurrency of 26 per repository (webhook 20, dispatcher 5, sweeper 1) | 1,000 concurrent executions per account by default, and at least 100 must stay unreserved: about 34 repositories | No reservation by default. A per-repository cap stays available as an option. Not an IAM item, but it is the first limit you would hit. |
| 5 roles per repository (deploy, webhook, control, runner, image build) | 1,000 roles per account by default, 10,000 at most: 200 or 2,000 repositories | Kept: these roles isolate repositories. Go past this with more accounts (cells). |
RecommendationPrincipal-tag ABAC, with the tag used inside resource ARNs
Every repository principal carries two tags: gha-repo-id (sha256(lower(owner/repo))[:10]) and gha-repo (owner/repo in lower case). The generic policy grants permissions on ARNs built from those tags with policy variables:
arn:aws:lambda:<region>:<account>:function:gha-microvm-${aws:PrincipalTag/gha-repo-id}-*
arn:aws:ssm:<region>:<account>:parameter/gha-microvm/${aws:PrincipalTag/gha-repo-id}/*
arn:aws:secretsmanager:<region>:<account>:secret:gha/${aws:PrincipalTag/gha-repo}/*
arn:aws:s3:::gha-microvm-artifacts-<account>-<region>/${aws:PrincipalTag/gha-repo-id}/*
Why this rather than plain resource-tag ABAC (aws:ResourceTag equal to aws:PrincipalTag on every statement):
- It works for every action that has a resource ARN. Some actions here have no
aws:ResourceTagcondition key, such as log stream writes, S3 objects and parts of the new Lambda MicroVMs API. A resource ARN always works. - Names can't change, tags can. Anyone allowed to tag a resource could otherwise move it into another repository. With names, a tag change on a resource grants nothing.
- Creates work too. The name in the request is checked before the resource exists, with no dependence on tag-on-create support.
- It doesn't care where the tag comes from. A role tag and a session tag are both
aws:PrincipalTag. The policy is the same in phase 1 and phase 2.
Resource tags are still used for three things:
- creates whose resource is
*(lambda:CreateMicrovmImage):aws:RequestTag/gha-repo-idmust equal the caller's tag. Network interfaces stay unscoped, because Lambda creates them and their requests carry no tag. - opt-in sharing: a secret or parameter tagged
gha-repo-id=<id>becomes readable by that repository's jobs, without any policy change - a second layer in the RCP, described below
IdentitiesWhere the tags come from
Phase 1: role tags
bootstrap creates one deploy role per repository, trusted by GitHub OIDC for one repository and Environment, and tagged with both keys. GitHub gives new repositories the immutable subject repo:<owner>@<owner_id>/<repo>@<repository_id>:environment:<env>. Set owner_id and repository_id in bootstrap.repositories (gh api repos/<owner>/<repo> --jq '.owner.id,.id') to trust exactly that subject, so a deleted and recreated repository with the same name gets nothing. Without them the trust accepts only repo:<owner>/<repo>:environment:<env>: Access Analyzer rejects a wildcard in place of an id, so a repository with the immutable subject needs its ids. All other repository roles are created by that deploy role. The policy only allows iam:CreateRole when the request carries the caller's own gha-repo-id and gha-repo values and the generic boundary. A repository can therefore only create roles of its own.
Phase 2: the tagger, with session tags
A role with session tags lets one shared deploy role serve every repository. GitHub can't provide this on its own. AssumeRoleWithWebIdentity takes session tags only from a https://aws.amazon.com/tags claim in the JWT, and GitHub's OIDC tokens don't include it. A small platform function, the tagger, does it instead. Enable it with bootstrap.tagger_github_owners; the example workflow is examples/consumer-repo/.github/workflows/deploy-runners-tagger.yml.
- The deploy workflow assumes the shared entry role
<prefix>-deploy-entrythrough OIDC. Its trust isrepo:<owner>/*:environment:*andrepo:<owner>@<owner_id>/*:environment:*(the immutable form), two lines per allowed GitHub owner.tagger_github_ownersmaps each owner to its numeric id, so an account that takes over a deleted owner's name matches neither line's id nor the tagger's check. It relies on GitHub's defaultsubtemplates: an organization with a custom template must adapt it. The entry role can only invoke the tagger. - The workflow sends a second GitHub OIDC token, with audience
<prefix>-tagger. The tagger acceptsRS256only, with a key from the issuer's JWKS (cached one hour, refreshed at most once a minute for an unknownkid). It checks the issuer and the audience exactly, andexp,nbfandiatwith one minute of clock skew. It never readssub: the repository and environment come from therepository,repository_ownerandenvironmentclaims, andrepository_owner_idmust equal the configured owner id. - The owner must be allowed, the registry entry must exist for the full repository name, and the token's
environmentmust equal the entry's. When the entry pins arepository_id, the token's must match. A reusedjtiis refused (DynamoDB conditional write with a TTL, KMS encrypted, point-in-time recovery). - The tagger calls
sts:AssumeRoleon<prefix>-deploywith session tagsgha-repo-idandgha-repo,SourceIdentity=<owner>+<repo>@<run_id>for CloudTrail, and at most one hour (role chaining). It returns the credentials and never logs them. - The shared deploy role trusts only the tagger, requires both tags and no other keys, and has no
gha-*role tags. The boundary'sTagMatchesNamestatement accepts its exact ARN, not adeploy*pattern. The SCP deniessts:TagSessionwith either key to every principal except the tagger, and protects<prefix>-deploy*and<prefix>-tagger*.
With phase 2, onboarding a repository only means writing its registry parameter. The per-repository deploy roles stay until per_repository_deploy_roles = false, so both paths can run side by side during a migration.
Generic boundary<prefix>-boundary, one per account
The same document is the deploy role's identity policy and the permissions boundary of every repository role, as before. It doesn't change when repositories are added.
| Scope | How |
|---|---|
| Functions, queues, tables, schedules, alarms, roles, log groups | Names <prefix>-${gha-repo-id}-* |
| MicroVM image and its VMs | ARN microvm-image:<prefix>-${gha-repo-id}*. Create needs aws:RequestTag/gha-repo-id equal to the caller's. |
| Platform-owned parameters and secrets | /<prefix>/${gha-repo-id}/*, <prefix>/${gha-repo-id}/* |
| Job secrets and parameters | By convention gha/${gha-repo}/* and /gha/${gha-repo}/*, or anything tagged gha-repo-id=${gha-repo-id} |
| Artifacts and state | S3 prefix ${gha-repo-id}/ |
| Role creation | Boundary must be <prefix>-boundary. Request tags must equal the caller's. |
| Extra job actions | additional_job_actions on bootstrap, the same for the whole account |
| Tag bound to the role name | A Deny on everything unless aws:PrincipalArn is role/<prefix>-${gha-repo-id}-* or role/<prefix>-deploy-${gha-repo-id}. If someone retags a role (for example deploy-B with A's id), it gets nothing, even without the SCP. gha-repo can't be tied to a name. It only widens reads of gha/<repo>/*, and the SCP is what protects it. Phase 2's shared deploy role needs an exception to this rule. |
| Explicit denies | Leaving the boundary, policy versions, users and access keys, the App secret, MicroVM shell and auth tokens, and changing gha-* tags to another value |
Organization guardrailsSCP, RCP and tag policy (module org-guardrails)
Every policy is generic: it holds only the name prefix and a list of exempt administrator roles. It is the same for every account and every number of repositories. The platform team attaches it to the workload OU from the management account or a delegated administrator.
SCP: makes the tags trustworthy
- DenyForeignRepoTags. A request that sets or removes
gha-repo-idorgha-repoon any resource or principal is denied unless the value equals the caller's own tag. This covers create-with-tags,TagResource,TagRoleand everyUntag*. Exempt administrators are excluded. Without this rule, anyone who can tag could pass for a repository. - DenyRepoSessionTags.
sts:TagSessionwith agha-repo-idtag is denied to everyone but the tagger role. - DenyBoundaryEscape. Principals tagged
gha-repo-idcan only create roles, or set a boundary, with<prefix>-boundary. They can't delete a boundary, create policy versions, users or access keys. - ProtectPlatform. Only exempt administrators can change the boundary policy and the platform roles: broker, deploy, tagger and connector operator.
- DenyMicrovmShell. MicroVM shell and auth tokens are denied across the organization, except for a break-glass role.
RCP: second layer on data
The RCP denies access to resources tagged gha-repo-id when the caller carries a different gha-repo-id. It covers Secrets Manager, SQS, DynamoDB, CloudWatch Logs, CloudWatch and X-Ray, the RCP-supported services used here. Callers with no gha-repo-id tag are left out (Null check), so administrators and AWS services are unaffected. A job's extra identity policy (additional_runner_policy_json), even one granting *, then still can't read another repository's secrets or queues.
Tag policy
Fixes the spelling and case of gha-repo-id and gha-repo and reports resources that don't comply. Tag policies can't require a tag or check a value against a pattern. The SCP does both.
Limits to know
- SCPs and RCPs don't apply to the management account or to service-linked roles.
- A deny on
StringNotEqualsalso matches a caller that lacks the key. That is why each SCP rule has the list of exempt administrator roles (for example the AWS SSO administrator roles and the platform pipeline role). - For actions without
aws:ResourceTag, the RCP doesn't apply. The identity layer, built on names, is the primary control, and the RCP is only the second one. - SCPs and RCPs are limited to 5,120 characters each, with up to 5 per target. The guardrails use one of each.
ScaleSize of one account (cell)
| Quota | Per repository | Repositories per account |
|---|---|---|
| IAM roles (1,000 by default, 10,000 at most) | 5 (4 with per_repository_deploy_roles = false) | 200 by default, 2,000 at most |
| Customer managed policies | 0 | No limit |
| Standard SSM parameters (10,000) | 2 or 3 plus one per running job | Thousands |
| Lambda concurrency and MicroVM memory | Depends on load | Size per account; raise the quotas or add a cell |
Past one account, assign repositories to cells. Each cell is an account with its own bootstrap, and the same SCP and RCP apply to all of them. A repository's deploy workflow points at its cell's role. Nothing is shared between cells, so a failure stays inside one cell.
MigrationBreaking changes before v0.1.0
repositories[*].job_secret_prefixes,job_parameter_pathsandadditional_job_actionsare removed. Use thegha/<owner>/<repo>/paths or tag a secret or parameter withgha-repo-id. Usebootstrap.additional_job_actionsfor the whole account.repo-runnerlosesjob_secret_prefixesandjob_parameter_paths, for the same reason.- The platform configuration has
boundary_arninstead ofboundaries. Runbootstrapfirst, then each repository. - The broker reads the registry instead of
ALLOWED_REPOSITORIES.