我使用Terraform创建了一个网络:
resource "google_compute_network" "vpc_network_shared" {
name = "vpc-shared-${var.workspace}"
auto_create_subnetworks = "false"
project = "${var.project}"
}
此文件位于模块shared_network
中:
module "shared_network" {
source = "network"
project = "${var.gcloud_project}"
workspace = "${terraform.workspace}"
}
但是我不能在集群中使用它:
resource "google_container_cluster" "gcloud_cluster" {
project = "${var.project}"
name = "gcloud-cluster-${var.workspace}"
zone = "${var.zone}"
remove_default_node_pool = true # This line is mandatory to delete the default node pool
initial_node_count = 1 # even though the default node pool is going to be deleted [remove_default_node_pool=1], we need to set an inicial node count before. Then, we must choose the minimum possible value, that is 1
cluster_ipv4_cidr = "10.32.0.0/14" # Pod address range (default was 10.32.0.0/14)
THIS NOT WORK:
network = "${module.shared_network.google_compute_network.vpc_network_shared.self_link}"
BUT THIS WORKS:
# network = "vpc-shared-${var.workspace}"
THIS NOT WORK:
subnetwork = "${module.shared_network.google_compute_subnetwork.sub_network-us-east1.self_link}"
BUT THIS WORKS:
# subnetwork = "sub-network-us-east1"
我收到此错误:
错误:资源'google_container_cluster.gcloud_cluster'配置: 引用的未知模块:shared_network
错误:资源'google_container_cluster.gcloud_cluster'配置: 引用未定义的模块“ shared_network”
如何通过路径而不是键入名称的方式将网络连接到群集?