Skip to content

feat(dynamic-labels): add allow-list mode to the AWS dynamic labels policy - #5411

Open
atsikham wants to merge 2 commits into
github-aws-runners:mainfrom
atsikham:feat/dynamic-labels-allowed-keys
Open

feat(dynamic-labels): add allow-list mode to the AWS dynamic labels policy#5411
atsikham wants to merge 2 commits into
github-aws-runners:mainfrom
atsikham:feat/dynamic-labels-allowed-keys

Conversation

@atsikham

@atsikham atsikham commented Sep 11, 2026

Copy link
Copy Markdown

Fixes #5412

Summary

aws_dynamic_labels_policy (the guardrail for ghr-ec2-* dynamic labels) only supports a blocklist: blocked_keys rejects specific keys, restricted_keys limits the values a specific key can have, and any key not on either list is allowed. This means a new EC2 override key GitHub adds later — or one that was simply left off the list — stays allowed until someone notices and blocks it. There was no way to set up a strict "nothing except these specific keys" policy without listing every single key to forbid.

Changes

  • Adds allowed_keys?: string[] to AwsDynamicLabelsPolicy. When set (not empty), any key not on that list is rejected — deny by default instead of allow by default. When it's unset or empty, nothing changes from today.
  • blocked_keys and restricted_keys keep working exactly as before, on their own.
  • allowed_keys and blocked_keys mean opposite things, so only one should be used per policy at a time:
    • Terraform checks this and fails plan/apply if both are set — checked everywhere this policy can be configured: the root module's aws_dynamic_labels_policy, modules/webhook's runner_matcher_config (used when configuring the webhook module directly), and both the old and new shapes of modules/multi-runner's multi_runner_config.
    • If a policy with both somehow still reaches the code some other way (for example, a hand-edited SSM parameter), it rejects every dynamic label instead of guessing which list to use.
  • Docs (docs/configuration.md) updated with an example for the allow-list next to the existing blocklist example, the new check order, and a note on why the allow-list closes a real gap the blocklist has — a blocklist can't protect against a future key that doesn't exist yet; an allow-list can.

Test plan

  • yarn test — new cases in dynamic-labels-policy.test.ts: unset/empty allowed_keys changes nothing, a key outside a non-empty allowed_keys is rejected, allowed_keys works together with restricted_keys, and the reject-everything behavior when both allowed_keys/blocked_keys are set. Full compute-providers (308 tests) and webhook (83 tests) suites pass.
  • yarn lint / yarn format / tsc --noEmit
  • terraform fmt -check / terraform validate on the root module, modules/webhook (standalone), and modules/multi-runner (standalone)

@atsikham
atsikham requested review from a team as code owners September 11, 2026 05:21
@atsikham
atsikham force-pushed the feat/dynamic-labels-allowed-keys branch 2 times, most recently from 106462a to 692cf97 Compare September 11, 2026 05:55
Comment thread modules/webhook/variables.tf Outdated
@edersonbrilhante

Copy link
Copy Markdown
Contributor

@atsikham The project requires signed your commits. Please sign so we can merge :)

…olicy

blocked_keys/restricted_keys are a deny-list: any key not named there
is allowed by default, so a new EC2 override key added upstream (or
one simply left off the list) is allowed until someone notices and
blocks it.

Add allowed_keys to AwsDynamicLabelsPolicy: when set (non-empty), any
dynamic label key not listed there is rejected, denying everything by
default except the keys named. blocked_keys and restricted_keys keep
working exactly as before; when allowed_keys is unset or empty,
behavior is unchanged. allowed_keys and blocked_keys are mutually
exclusive per policy - Terraform validation rejects configuring both
in every place this policy can be set (the root module's
aws_dynamic_labels_policy, modules/webhook's runner_matcher_config
configured directly, and both the v1 and v2 shapes of
modules/multi-runner's multi_runner_config), and the evaluator fails
closed (rejects every dynamic label) if a policy with both somehow
reaches the dispatcher some other way (e.g. a hand-edited SSM
parameter).

modules/webhook's runner_matcher_config now types
awsDynamicLabelsPolicy as a proper nested object instead of any,
matching the pattern already used in modules/multi-runner's v2 shape
(review feedback on PR github-aws-runners#5411).
@atsikham
atsikham force-pushed the feat/dynamic-labels-allowed-keys branch from 692cf97 to af089e1 Compare September 12, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic labels policy has no allow-list mode, only deny-list

2 participants