【问题标题】:google_cloudfunctions2_function not supported in terraformterraform 不支持 google_cloudfunctions2_function
【发布时间】:2022-08-18 20:10:05
【问题描述】:

我正在尝试在 gcp 中使用 terraform 提供版本 2 云功能。资源如下所示:

resource \"google_cloudfunctions2_function\" \"function\" {
  provider = google-beta
  name = \"test-function\"
  location = \"us-central1\"
  description = \"a new function\"

当我运行计划时,我得到了这个

 Error: Invalid resource type
│
│   on main.tf line 49, in resource \"google_cloudfunctions2_function\" \"function\":
│   49: resource \"google_cloudfunctions2_function\" \"function\" {
│
│ The provider hashicorp/google-beta does not support resource type \"google_cloudfunctions2_function\". Did you mean \"google_cloudfunctions_function\"?

我注意到了什么。我无法使用 gcloud cli 看到当前存在的第 2 版云功能:

me@cloudshell:~ (the-project-im-using)$ gcloud functions list
Listed 0 items.
me@cloudshell:~ (the-project-im-using)$ gcloud beta functions list
Listed 0 items.
me@cloudshell:~ (the-project-im-using)$ gcloud alpha functions list
Listed 0 items.
me@cloudshell:~ (the-project-im-using)$

我是否正确假设这表明无法通过 rest api 访问第 2 版云功能?

我可以找到的参考文档在这里: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloudfunctions2_function https://cloud.google.com/functions/docs/tutorials/terraform

谢谢!

    标签: google-cloud-platform google-cloud-functions terraform


    【解决方案1】:

    我怀疑这个问题与当前在 Cloud Shell 中运行的 Terraform 和 gcloud CLI 版本有关。

    使用release 395.0.0 of gcloud,添加了列出第二代云函数的功能:

    更新了 gcloud 函数列表以返回除第一代函数之外的第二代函数。

    如果您运行的是较低版本(我的最初版本为 394),则不会列出第二代功能。请记住,您仍然可以使用 gcloud run services list 列出底层 Cloud Run 服务。

    至于 Terraform,我的 Cloud Shell 部署第二代功能没有问题。我的本地机器具有两个软件包的最新版本,也可以毫无问题地部署。

    我建议您使用这些软件包的最新版本在本地计算机上部署该功能。否则,由于 Cloud Shell 是托管的并且可能会重置为默认安装,您也可以尝试customizing the container 或等待默认安装更新。让我知道这是否有用。

    【讨论】:

      【解决方案2】:

      关注Terraform Tutorial (2nd gen) 时,我在这里遇到了同样的问题

      $terraform plan

      $terraform plan
      

      错误:资源类型无效 │ │ 在 main.tf 第 17 行,在资源中 "google_cloudfunctions2_function" "function": │ 17: 资源 "google_cloudfunctions2_function" "function" { │ 提供者 hashcorp/google 不支持资源类型 “google_cloudfunctions2_function”。你的意思 “google_cloudfunctions_function”?

      【讨论】:

        猜你喜欢
        • 2021-12-29
        • 2018-10-20
        • 1970-01-01
        • 1970-01-01
        • 2021-11-11
        • 2021-06-27
        • 2019-01-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多