我正在尝试为区域负载均衡器创建保留子网。这是我第一次使用 google-beta 提供程序,当我尝试使用以下脚本创建子网时......:
resource "google_compute_subnetwork" "proxy-subnet" {
provider = google-beta
project = "proyecto-pegachucho"
name = "website-net-proxy"
ip_cidr_range = "10.10.50.0/24"
region = "us-central1"
network = google_compute_network.HSBC_project_network.self_link
purpose = "INTERNAL_HTTPS_LOAD_BALANCER"
role = "ACTIVE"
}
...出现此错误:
Error: Error creating Subnetwork: googleapi: Error 403: Required 'compute.subnetworks.create' permission for 'projects/proyecto-pegachucho/regions/us-central1/subnetworks/website-net-proxy'
More details:
Reason: forbidden, Message: Required 'compute.subnetworks.create' permission for 'projects/proyecto-pegachucho/regions/us-central1/subnetworks/website-net-proxy'
Reason: forbidden, Message: Required 'compute.networks.updatePolicy' permission for 'projects/proyecto-pegachucho/global/networks/hsbc-vpc-project'
on .terraform\modules\networking\networking.tf line 18, in resource "google_compute_subnetwork" "proxy-subnet":
18: resource "google_compute_subnetwork" "proxy-subnet" {
这没有任何意义,因为我在我的服务帐户中拥有所有者角色并且启用了权限。我能做什么?
编辑:我解决了它直接在模块中添加提供程序,如下所示:
provider "google-beta" {
project = var.project
region = var.region
credentials = "./mario.json"
}
resource "google_compute_health_check" "lb-health-check-global" {
name = var.healthckeck_name
check_interval_sec = var.check_interval_sec
timeout_sec = var.timeout_sec
healthy_threshold = var.healthy_threshold
unhealthy_threshold = var.unhealthy_threshold # 50 seconds
tcp_health_check {
port = var.healthckeck_port
}
}
resource "google_compute_region_health_check" "lb-health-check-regional" {
provider = google-beta
region = var.region
project = var.project
name = "healthcheck-regional"
check_interval_sec = var.check_interval_sec
timeout_sec = var.timeout_sec
healthy_threshold = var.healthy_threshold
unhealthy_threshold = var.unhealthy_threshold # 50 seconds
tcp_health_check {
port = var.healthckeck_port
}
}