1

Error: Incorrect attribute value type当传递var_3tfe_variableHCL 类型的下方时,我正在击中。有没有办法将解码的 JSON 变量转换为 HCL?

我的config.json

{
    "vars": {
        "var_1": "foo",
        "var_2": "bar",
        "var_3": {
            "default": "foo"
        }
    }
}

我的地形配置:


variable "tfe_token" {}

provider "tfe" {
  hostname = "app.terraform.io"
  token    = var.tfe_token
}

data "tfe_workspace" "this" {
  name         = "my-workspace-name"
  organization = "my-org-name"
}

locals {
  json_config = jsondecode(file("config.json"))
}

resource "tfe_variable" "workspace" {
  for_each = local.json_config.vars

  workspace_id = data.tfe_workspace.this.id
  key          = each.key
  value        = each.value
  category     = "terraform"
  hcl          = true
  sensitive    = false
}


4

0 回答 0