Repository navigation
fix(runners): fix type mismatch in pool role conditional - #5156
Merged
Merged
Conversation
The conditional for the runner role in pool.tf returned inconsistent types: the true branch produced an object with a single 'arn' attribute while the false branch returned the full aws_iam_role resource (16 attributes). Terraform requires both branches to have consistent types. Move the conditional inside the object so both branches produce a string for the 'arn' key. Fixes type error introduced in #4875. Signed-off-by: Brend Smits <[email protected]>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Brend-Smits
added a commit
to philips-forks/terraform-aws-github-runner
that referenced
this pull request
Jun 11, 2026
The conditional for the runner role in pool.tf returned inconsistent types: the true branch produced an object with a single 'arn' attribute while the false branch returned the full aws_iam_role resource (16 attributes). Terraform requires both branches to have consistent types. Move the conditional inside the object so both branches produce a string for the 'arn' key. Fixes type error introduced in github-aws-runners#4875. Upstream-PR: github-aws-runners#5156
edersonbrilhante
approved these changes
Jun 11, 2026
edersonbrilhante
pushed a commit
that referenced
this pull request
Jun 11, 2026
🤖 I have created a release *beep* *boop* --- ## [7.7.1](v7.7.0...v7.7.1) (2026-06-11) ### Bug Fixes * **runners:** fix type mismatch in pool role conditional ([#5156](#5156)) ([60de50f](60de50f)) --- 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>
7 of 13 tasks
edersonbrilhante
added a commit
that referenced
this pull request
Jul 3, 2026
## Problem `terraform validate` cannot detect conditional type mismatches like the one introduced in #4875: ```hcl role = var.iam_overrides["override_runner_role"] ? { arn = var.iam_overrides["runner_role_arn"] } : aws_iam_role.runner[0] ``` This passes `terraform validate` but fails at plan time because the two branches produce objects with different attributes (1 vs 16). ## Solution Add a `terraform test` file (`modules/runners/tests/pool.tftest.hcl`) that uses mock providers to run a full plan of the runners module with pool enabled. This catches type errors that `validate` misses, without requiring AWS credentials. Also adds a `terraform_test` job to the existing CI workflow. The job uses Terraform `latest` (requires 1.7+ for `mock_provider` / `mock_data` support) and runs `terraform test` on modules that have test files. ### Verified locally With the buggy code (before #5156): ``` Error: Inconsistent conditional result types on pool.tf line 54, in module "pool": The true and false result expressions must have consistent types. ``` With the fix (#5156 applied): ``` Success! 1 passed, 0 failed. ``` ## Future work The `terraform_test` job matrix can be expanded as more modules add `.tftest.hcl` files. This is a starting point to catch the class of bugs that `validate` cannot. --------- Signed-off-by: Brend Smits <[email protected]> Co-authored-by: Niek Palm <[email protected]> Co-authored-by: Ederson Brilhante <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The conditional for the runner role in
modules/runners/pool.tf(introduced in #4875) returns inconsistent types:{ arn = "..." }(1 attribute)aws_iam_role.runner[0](16 attributes includingassume_role_policy,name, etc.)Terraform requires both branches of a conditional to have consistent types. This causes a type error at plan time when
override_runner_role = false(the default).Fix
Move the conditional inside the object so both branches produce a string:
This is consistent with how
scale-up.tf(line 123) already handles the same conditional.Testing
terraform plansucceeds withoverride_runner_role = false(default)object({ arn = string }), so only the.arnattribute is needed