GCP 负载均衡器的运行状况检查(来自 terraform)

时间:2021-07-30 11:23:39

标签: google-cloud-platform terraform terraform-provider-gcp

我正在尝试为 Terraform 创建 GCP 基础架构,更准确地说,是使用模块“gce-lb-http”的负载均衡器。以下是错误:

╷
│ Error: Error creating HealthCheck: googleapi: Error 403: Required 
'compute.healthChecks.create' permission for 'projects/gcptf- 
320808/global/healthChecks/tf-createdlb-hc-default', forbidden 
│  
│   with module.gce-lb-http.google_compute_health_check.default["default"],
│   on .terraform/modules/gce-lb-http/main.tf line 203, in resource 
"google_compute_health_check" "default":
│  203: resource "google_compute_health_check" "default" {

所以我不知道为什么禁止创建健康检查?我怎样才能允许创建这个?

1 个答案:

答案 0 :(得分:1)

由 Terraform 触发的您的用户(或服务帐户)需要此权限才能创建 HealthChecks 'compute.healthChecks.create'。你

如果服务帐户具有正确的权限,请检查配置文件中定义的项目 ID,这是使用项目名称而不是项目 ID 的常见错误,或者只是拼错 ID 本身。

如果您需要某些特定权限,请查看描述如何add roles to a service account 和如何make custom roles 的文档。

您可能还会发现 this question & answer 很有用。