0

我正在尝试访问Kubernetes_secret data.tokenterraform 中的属性,但我不断收到错误消息

Resource 'data.kubernetes_secret.misp_whitelist_secret' does not have attribute 'data.token' for variable 'data.kubernetes_secret.misp_whitelist_secret.data.token'

解决这个问题的方法是什么?

resource "kubernetes_service_account" "misp_whitelist_sa" {
  metadata {
    name = "misp-whitelist-sa"
  }
}

data "kubernetes_secret" "misp_whitelist_secret" {
  metadata {
    name      = "${kubernetes_service_account.misp_whitelist_sa.default_secret_name}"
    namespace = "${kubernetes_service_account.misp_whitelist_sa.metadata.0.namespace}"
  }
  depends_on = [
    "kubernetes_service_account.misp_whitelist_sa",
  ]
}

我正在尝试访问 terraform google_cloud_function 资源中的 data.token

resource "google_cloudfunctions_function" "misp_whitelist_function" {
  name    = "${var.cluster}-misp-whitelist"
  ....<additional data> .....
  environment_variables = {
    CLUSTER = "${var.cluster}"
    PROJECT = "${var.project}"
    AUTH = "${data.kubernetes_secret.misp_whitelist_secret.data.token}"
  }
}

4

1 回答 1

0

访问数据密钥的正确方法是:

AUTH = "${data.kubernetes_secret.misp_whitelist_secret.data["token"]}"
于 2019-12-06T19:07:12.383 回答