【问题标题】:How can I use the output of Tarraform Coud workspace as provider configuration?如何使用 Terraform Cloud 工作区的输出作为提供者配置?
【发布时间】:2021-05-09 17:26:52
【问题描述】:

我有一个创建 AKS 群集的工作区,该群集每天都会被销毁和重新创建。我有另一个将应用程序堆栈部署到集群中的工作区。每天我都必须将生成的主机和凭据复制到应用程序堆栈工作区中,这既繁琐又容易出错。

因此我们的想法是获取 AKS 工作区的输出并在 kubernetes 堆栈中使用它们,基于此 https://www.terraform.io/docs/language/data-sources/index.html

但是,设置没有加载,我的理论是数据源不能在提供程序模块中使用,只有资源?

data "terraform_remote_state" "aks" {
  backend = "remote"
  config = {
    organization = "xxxx"
    workspaces = {
      name = "aks_prod"
    }
  }
}

provider "kubernetes" {
  host = data.terraform_remote_state.aks.outputs.host

  client_certificate = base64decode(data.terraform_remote_state.aks.outputs.client_certificate)
  client_key = base64decode(data.terraform_remote_state.aks.outputs.client_certificate)
  cluster_ca_certificate = base64decode(data.terraform_remote_state.aks.outputs.client_certificate)
}

如果这是真的,那么我可能不得不使用 REST API 将输出推送到我的工作区,但显然如果可能的话,我更愿意使用原生 Terraform 解决方案。

【问题讨论】:

    标签: terraform


    【解决方案1】:

    它确实与 Provider 完美配合!我正在用数据替换输入变量,但忘记实际删除变量定义,doh!

    【讨论】:

      猜你喜欢
      • 2021-07-17
      • 2021-06-19
      • 2023-01-19
      • 1970-01-01
      • 1970-01-01
      • 2018-12-14
      • 1970-01-01
      • 2018-06-01
      • 2018-12-23
      相关资源
      最近更新 更多