You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Terraform中YAML配置GitHub Runner模块变量传递错误解决

问题解决方法

错误原因

你的YAML配置文件(linux-arm64.yaml)里引用了变量 ${pool_org},但在templatefile函数的变量映射中,你传入的键是pool_runner_owner,两者名称不匹配,导致Terraform找不到对应的变量。

解决方案(二选一即可)

方案1:修改YAML模板中的变量名

把YAML里的pool_runner_owner: "${pool_org}"改成pool_runner_owner: "${pool_runner_owner}",和传入的变量键保持一致:

runner_config:
  # ... 其他配置 ...
  pool_runner_owner: "${pool_runner_owner}"
  # ... 其他配置 ...

方案2:修改locals中的变量映射键名

在locals的templatefile变量映射里,把pool_runner_owner改成pool_org,匹配YAML里的引用:

locals {
  multi_runner_config = {
    for c in fileset("${path.module}/templates/runner-configs", "*.yaml") :
    trimsuffix(c, ".yaml") => {
      config = yamldecode(templatefile("${path.module}/templates/runner-configs/${c}", {
        pool_org                             = var.pool_org, # 这里改成pool_org
        pool_config                         = jsonencode(var.pool_config),
        runner_iam_role_managed_policy_arns = jsonencode(var.managed_policy_arns),
        block_device_mappings               = jsonencode(var.block_device_mappings),
        ami_owners                          = jsonencode(var.ami_owners),
        ami_filter                          = jsonencode(var.ami_filter)
      }))
    }
  }
}

额外注意

YAML里的pool_config: ${(pool_config)}存在多余括号,建议改成pool_config: ${pool_config},避免后续可能出现的解析错误。

内容的提问来源于stack exchange,提问作者cloudbud

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 16:52:44