Skip to content

feat: Make runner trust policy extendable - #5275

Open
chris-griffin wants to merge 1 commit into
github-aws-runners:mainfrom
chris-griffin:feat/runner-trust-policy
Open

feat: Make runner trust policy extendable#5275
chris-griffin wants to merge 1 commit into
github-aws-runners:mainfrom
chris-griffin:feat/runner-trust-policy

Conversation

@chris-griffin

@chris-griffin chris-griffin commented Aug 16, 2026

Copy link
Copy Markdown

Description

Adds a configuration option so that the runner trust policy can be extended. Currently, it is hardcoded via modules/runners/policies/instance-role-trust-policy.json

Test Plan

  • terraform test, terraform validate and terraform fmt -check all passed
  • tflint passed although it did raise a warning unrelated to this change
  • We have not deployed this exact version yet, but happy to do so if helpful or required

Related Issues

Would address previously requested use cases like #4247 and #1315

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.

Pull request overview

Adds an input hook to extend the runner instance-role trust policy (assume-role policy) with additional IAM statements, addressing requests to parameterize/append trust relationships for cross-account use cases.

Changes:

  • Introduces runner_iam_role_additional_trust_policy_statements at the root and runners module levels (and wires it through multi-runner).
  • Updates runner IAM role creation to append user-provided trust policy statements to the existing default trust policy.
  • Adds a Terraform test verifying default behavior and appended-statement ordering, and updates module/root READMEs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
variables.tf Adds new root input variable for additional runner trust policy statements.
main.tf Passes the new variable into the runners module.
README.md Documents the new root input.
modules/runners/variables.tf Adds the corresponding runners-module input variable.
modules/runners/policies-runner.tf Appends additional trust statements when rendering assume_role_policy.
modules/runners/tests/runner-trust-policy.tftest.hcl Adds coverage for default and extended trust policy behavior.
modules/runners/README.md Documents the new runners-module input.
modules/multi-runner/variables.tf Extends multi_runner_config.runner_config schema to include the new option.
modules/multi-runner/runners.tf Wires the new option through to the runners module.
modules/multi-runner/README.md Updates multi-runner docs to include the new option.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +437 to +446
variable "runner_iam_role_additional_trust_policy_statements" {
description = "Additional statements appended to the trust policy (assume role policy) of the runner IAM role. Statements are in the IAM policy statement format. For example to allow the EC2 service to pass session tags add `[{ Effect = \"Allow\", Principal = { Service = \"ec2.amazonaws.com\" }, Action = \"sts:TagSession\" }]`."
type = any
default = []

validation {
condition = can([for statement in var.runner_iam_role_additional_trust_policy_statements : statement])
error_message = "The variable `runner_iam_role_additional_trust_policy_statements` must be a list of IAM policy statements."
}
}
assume_role_policy = jsonencode(merge(local.runner_role_trust_policy, {
Statement = concat(
local.runner_role_trust_policy.Statement,
var.runner_iam_role_additional_trust_policy_statements
Comment thread variables.tf
Comment on lines +535 to +544
variable "runner_iam_role_additional_trust_policy_statements" {
description = "Additional statements appended to the trust policy (assume role policy) of the runner IAM role. Statements are in the IAM policy statement format. For example to allow the EC2 service to pass session tags add `[{ Effect = \"Allow\", Principal = { Service = \"ec2.amazonaws.com\" }, Action = \"sts:TagSession\" }]`."
type = any
default = []

validation {
condition = can([for statement in var.runner_iam_role_additional_trust_policy_statements : statement])
error_message = "The variable `runner_iam_role_additional_trust_policy_statements` must be a list of IAM policy statements."
}
}
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.

2 participants