Skip to content

fix(termination-watcher): grant kms:Decrypt for GitHub App parameters - #5562

Merged
Brend-Smits merged 3 commits into
github-aws-runners:mainfrom
Brend-Smits:fix/termination-watcher-kms-decrypt
Oct 29, 2026
Merged

Brend-Smits merged 3 commits into
github-aws-runners:mainfrom
Brend-Smits:fix/termination-watcher-kms-decrypt

Conversation

@Brend-Smits

Copy link
Copy Markdown
Contributor

Description

The termination-watcher Lambdas (notification, handler and deregister-retry) read the GitHub App credentials from SSM to deregister runners. If those parameters are SecureStrings encrypted with a customer-managed KMS key, the roles have no kms:Decrypt on it, so the read fails and the runner is never deregistered. #5467 fixed the SSM actions and parameter list, so this is the next thing that breaks.

This adds an optional github_app_kms_key_arn to the watcher config. When it is set and deregistration is enabled, all three roles get kms:Decrypt on that key. The SSM and KMS statements are built once and shared by the three roles. multi-runner passes the SSM storage provider key and the root module passes kms_key_arn, so nobody has to change their inputs. Without a key, or with deregistration off, the policy is the same as before.

Prior attempt in #5274, which is no longer active. It also changed how environment variables are preserved, which I left out here to keep this to the KMS access.

Test Plan

  • New modules/termination-watcher/tests/kms.tftest.hcl: key set (SSM actions on all primary, additional-app and manifest ARNs plus kms:Decrypt on only that key), no key, single app, deregistration disabled with a key set, and a key that is only known after apply.
  • terraform test in modules/termination-watcher and modules/multi-runner, terraform validate in both and at the root, terraform fmt -check -recursive.
  • yarn test, yarn lint and yarn format-check in lambdas.
  • Not deployed anywhere yet.

Related Issues

Builds on #5467. Supersedes the KMS part of #5274.

@Brend-Smits
Brend-Smits marked this pull request as ready for review October 28, 2026 14:16
@Brend-Smits
Brend-Smits requested review from a team as code owners October 28, 2026 14:16
Brend-Smits and others added 2 commits October 28, 2026 15:17
The termination notification, termination handler and deregister-retry
Lambdas read the GitHub App credentials from SSM Parameter Store. When
the parameters are SecureStrings encrypted with a customer-managed KMS
key, the roles had no kms:Decrypt on it, so every read failed and
runners were never deregistered.

Add an optional github_app_kms_key_arn to the module config and build
the credential-read policy once, so all three roles get the SSM actions
and kms:Decrypt scoped to that key. The root module passes kms_key_arn
and multi-runner passes the SSM storage provider key, so consumers need
no new input. Deregistration disabled or no key keeps the previous
policy.

Builds on github-aws-runners#5467 and the earlier attempt in github-aws-runners#5274.

Signed-off-by: Brend Smits <[email protected]>
@Brend-Smits
Brend-Smits requested a balanced review from Copilot October 28, 2026 14:18
@Brend-Smits
Brend-Smits force-pushed the fix/termination-watcher-kms-decrypt branch from 3faaec1 to 5418894 Compare October 28, 2026 14:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The tests do not verify the roles’ actual SSM/KMS policy attachments and would still pass if those attachments were removed, leaving the targeted regression uncovered.

1 open issue
What changed in this PR

This PR adds scoped KMS decryption permissions so termination-watcher Lambdas can read GitHub App credentials encrypted with a customer-managed key and deregister runners.

Changes:

  • Adds an optional KMS key ARN and forwards existing root and multi-runner key settings.
  • Shares the SSM/KMS credential policy across notification, termination-handler, and retry roles.
  • Adds Terraform tests for configured, absent, and apply-time key values, plus disabled deregistration.
File Description
modules/​termination-watcher/​variables.tf Defines and documents the optional KMS key ARN.
modules/​termination-watcher/​tests/​kms.tftest.hcl Adds KMS policy and configuration tests.
modules/​termination-watcher/​tests/​fixtures/​computed-kms/​versions.tf Declares fixture Terraform and provider requirements.
modules/​termination-watcher/​tests/​fixtures/​computed-kms/​README.md Documents the computed-key fixture.
modules/​termination-watcher/​tests/​fixtures/​computed-kms/​main.tf Supplies a key ARN unknown until apply.
modules/​termination-watcher/​termination/​main.tf Uses the shared credential policy for the handler.
modules/​termination-watcher/​README.md Documents the new configuration option.
modules/​termination-watcher/​notification/​main.tf Uses the shared credential policy for notifications.
modules/​termination-watcher/​main.tf Builds the shared SSM policy with optional KMS access.
modules/​termination-watcher/​deregister-retry.tf Uses the shared credential policy for retries.
modules/​multi-runner/​termination-watcher.tf Forwards the SSM storage provider’s KMS key.
main.tf Forwards the root module’s KMS key ARN.

Review effort: Balanced

Brend-Smits added a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Oct 28, 2026
Check the policy actually attached to the deregister-retry role, and
add child-module runs for the notification and handler roles, so the
tests fail if a role loses its SSM/KMS policy.

Signed-off-by: Brend Smits <[email protected]>
@Brend-Smits

Copy link
Copy Markdown
Contributor Author

This change is verified working (tested in our staging environment). So we are good to merge it after getting the reviews in.

@Brend-Smits
Brend-Smits enabled auto-merge (squash) October 28, 2026 16:22
@Brend-Smits
Brend-Smits merged commit 7b54664 into github-aws-runners:main Oct 29, 2026
55 checks passed
guicaulada pushed a commit that referenced this pull request Nov 3, 2026
🤖 I have created a release *beep* *boop*
---


##
[8.1.0](v8.0.0...v8.1.0)
(2026-10-29)


### Features

* add stateless registration cleanup with multi-App support
([#5465](#5465))
([5959d43](5959d43))
* **termination-watcher:** support additional GitHub Apps
([#5467](#5467))
([eefcb1e](eefcb1e))


### Bug Fixes

* **lambda:** bump undici from 6.29.0 to 6.29.1 in /lambdas
([#5554](#5554))
([94f46c7](94f46c7))
* **scale-down:** clean EC2 runners incrementally and isolate failures
([#5463](#5463))
([60a4c66](60a4c66))
* **scale-down:** scope cached clients by selected GitHub App
([#5466](#5466))
([bbd92fe](bbd92fe))
* **termination-watcher:** grant kms:Decrypt for GitHub App parameters
([#5562](#5562))
([7b54664](7b54664))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: runners-releaser[bot] <194412594+runners-releaser[bot]@users.noreply.github.com>
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.

3 participants