可以通过Terraform设置云功能的秘密吗?

发布于 2025-01-23 08:08:45 字数 1255 浏览 0 评论 0原文

Terraform Google_cloudfunctions_function资源文档列表秘密环境变量是可选的参数。我要么无法正确使用它,要么与文档相反,实际上并不支持它。

resource "google_cloudfunctions_function" "function" {
  name        = var.function_name
  runtime     = "nodejs16"

  available_memory_mb   = 128
  source_archive_bucket = google_storage_bucket.bucket.name
  source_archive_object = google_storage_bucket_object.zip.name
  trigger_http          = true
  entry_point           = var.function_entry_point

  secret_environment_variables = []
}

结果:

错误:模块/云功能/main.tf上的不支持的参数 第51行,在资源“ Google__cloudfunctions_function”“ function”中: 51:secret_environment_variables = {}一个名为的参数 这里不期望“ secret_environment_variables”。你是说 定义类型“ secret_environment_variables”类型?

这是Terraform版本的结果:

Terraform v1.1.9
on darwin_amd64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/external v2.2.2
+ provider registry.terraform.io/hashicorp/google v4.18.0

The Terraform google_cloudfunctions_function resource documentation lists secret environment variables as an optional argument. I'm either not using it correctly or, contrary to the documentation, it's not in fact supported.

resource "google_cloudfunctions_function" "function" {
  name        = var.function_name
  runtime     = "nodejs16"

  available_memory_mb   = 128
  source_archive_bucket = google_storage_bucket.bucket.name
  source_archive_object = google_storage_bucket_object.zip.name
  trigger_http          = true
  entry_point           = var.function_entry_point

  secret_environment_variables = []
}

results in:

Error: Unsupported argument on modules/cloud-function/main.tf
line 51, in resource "google_cloudfunctions_function" "function":
51: secret_environment_variables = {} An argument named
"secret_environment_variables" is not expected here. Did you mean to
define a block of type "secret_environment_variables"?

This is the result of terraform version:

Terraform v1.1.9
on darwin_amd64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/external v2.2.2
+ provider registry.terraform.io/hashicorp/google v4.18.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吖咩 2025-01-30 08:08:45

根据文档,该密钥应为阻止。这是一个示例:

resource "google_cloudfunctions_function" "function" {
  name        = var.function_name
  runtime     = "nodejs16"

  available_memory_mb   = 128
  source_archive_bucket = google_storage_bucket.bucket.name
  source_archive_object = google_storage_bucket_object.zip.name
  trigger_http          = true
  entry_point           = var.function_entry_point

  secret_environment_variables {
    key = "myvar"
    secret = "mysecret_id"
  }
}

According to the documentation, that key should be block. Here is an example:

resource "google_cloudfunctions_function" "function" {
  name        = var.function_name
  runtime     = "nodejs16"

  available_memory_mb   = 128
  source_archive_bucket = google_storage_bucket.bucket.name
  source_archive_object = google_storage_bucket_object.zip.name
  trigger_http          = true
  entry_point           = var.function_entry_point

  secret_environment_variables {
    key = "myvar"
    secret = "mysecret_id"
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文