【问题标题】:Deploy GCP Cloud functions to Artifact Registry using Terraform使用 Terraform 将 GCP Cloud 函数部署到 Artifact Registry
【发布时间】:2022-02-08 05:21:54
【问题描述】:

我正在尝试使用 Terraform 将云功能部署到工件注册表而不是容器注册表。

我在 GCP 中创建了一个工件存储库并使用 google-beta 提供程序。 但我不明白在哪里提到“docker-registry”路径(工件注册表的路径)

在我的主 tf 文件创建 CF 之后:- 我基于https://cloud.google.com/functions/docs/building#image_registry_options 添加了一个名为 docker-repository 的参数(这在 terraform 中不存在) 但看起来这个参数在 terraform 中不存在并且给了我错误。

resource "google_cloudfunctions_function" "appConfigService" {
  provider              = google-beta
  name                  = local.function_names.appConfigService
  description           = "helloWorld"
  runtime               = var.cf_node_run_time
  available_memory_mb   = var.cf_memory
  source_archive_bucket = local.deployment_bucket
  source_archive_object = google_storage_bucket_object.appConfigService_archive.name
  entry_point           = "helloWorld"
  service_account_email = var.default_service_account[var.environment]
  trigger_http          = true
  docker-repository     ="<artifact registry path>" //This is wrong

}

我无法在任何地方找到有关此的任何文档。 请告诉我使用 terraform 将 Cloud 函数部署到工件存储库的正确方法。

【问题讨论】:

  • 我不知道这个新参数。我确定 Terraform 提供程序也不是最新的。
  • docker-registry 参数在 terraform 中不存在,我正在寻找 terraform 中的等价物。如果您已通过 Terraform 部署到工件注册表,请发布您的代码

标签: google-cloud-platform google-cloud-functions terraform continuous-deployment google-artifact-registry


【解决方案1】:

此时,您将需要使用 Terraform 和 Cloud Build 来指定要使用的存储库。然后,您可以在 Cloud Build 步骤中使用 gcloud --docker-repository

本文档介绍了如何将 Terraform 与 Cloud Build 集成。

Managing infrastructure as code with Terraform, Cloud Build, and GitOps

【讨论】:

  • 事实证明,这是目前唯一的方法,除非 terraform 添加此功能,否则我们无能为力。
猜你喜欢
  • 2022-01-27
  • 1970-01-01
  • 2022-01-23
  • 2021-05-31
  • 2022-01-07
  • 2022-10-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多