【问题标题】:gcp cloud run, how to define multiple secret volumes via terraform, currently only 1 secret seems supported in documentationgcp 云运行,如何通过 terraform 定义多个秘密卷,目前文档中似乎只支持 1 个秘密
【发布时间】:2022-10-08 01:15:14
【问题描述】:

目前,云运行 here 的 terraform 文档向您展示了如何将 1 个单独的秘密卷挂载到云运行服务的示例。

  template {
    spec {
      containers {
        image = "gcr.io/cloudrun/hello"
        volume_mounts {
          name = "a-volume"
          mount_path = "/secrets"
        }
      }
      volumes {
        name = "a-volume"
        secret {
          secret_name = google_secret_manager_secret.secret.secret_id
          default_mode = 292 # 0444
          items {
            key = "1"
            path = "my-secret"
            mode = 256 # 0400
          }
        }
      }
    }
  }

我尝试添加多个 volumessecret 块,但这会出错,说只允许 1 个。

我还尝试通过文档查看多卷的一般示例,但不存在这样的示例。

【问题讨论】:

  • 是否可以以任何其他方式定义多个卷,例如,使用 Web 控制台或 CLI?

标签: terraform terraform-provider-gcp


【解决方案1】:

在 terraform 文档中,您可以看到:“规范块支持:......卷 - (可选)卷表示容器中的命名卷。结构是”

您需要在规范上下文中使用卷标签。像这样

spec {
  containers {
    volume_mounts {
      mount_path = "/secrets"
      name = "secret"
    }        
  }

    **volumes {
    name = "secret"
    secret {
      secret_name = "secret name"
    }
  }**
}

【讨论】:

    猜你喜欢
    • 2021-10-26
    • 2020-12-04
    • 2020-11-06
    • 2022-01-03
    • 2016-08-21
    • 1970-01-01
    • 2019-11-14
    • 1970-01-01
    • 2020-10-01
    相关资源
    最近更新 更多