我创建了一个Terraform模块,用于在Google中部署VPC,其中的一部分是:
resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" {
name = var.vpc_subnet_name
ip_cidr_range = var.ip_cidr_range
region = var.vpc_region
network = google_compute_network.vpc_network.id
secondary_ip_range {
range_name = var.services_secondary_range_name
ip_cidr_range = var.services_secondary_cidr_range
}
secondary_ip_range {
range_name = var.pods_secondary_range_name
ip_cidr_range = var.pods_secondary_cidr_range
}tf计划访问的main.tf文件由Python更新,以提供唯一的CIDR范围,以确保部署的网络不重叠。这就设置了以下内容:
ip_cidr_range = "10.51.0.0/20"
pods_secondary_cidr_range = "10.52.0.0/20"
services_secondary_cidr_range = "10.53.0.0/20"然而,信托基金计划抱怨:
*"ip_cidr_range“不是有效的IP CIDR范围:无效的CIDR地址:
用module.ic-vpc.google_compute_subnetwork.network-with-private-secondary-ip-ranges,
在..terraform/modules/ic/main.tf第11行中,资源"google_compute_subnetwork“中的”网络-具有-私有-次要-ip-范围“:11: ip_cidr_range = var.ip_cidr_range
"secondary_ip_range.0.ip_cidr_range“不是有效的IP CIDR范围:无效的CIDR地址:
在..terraform/ module.ic-vpc.google_compute_subnetwork.network-with-private-secondary-ip-ranges,/ic/main.tf第16行中,资源"google_compute_subnetwork“中的”网络-具有私有-次要-ip-范围“:16: ip_cidr_range = var.services_secondary_cidr_range
"secondary_ip_range.1.ip_cidr_range“不是有效的IP CIDR范围:无效的CIDR地址:
在..terraform/ module.ic-vpc.google_compute_subnetwork.network-with-private-secondary-ip-ranges,/ip/main.tf第20行中,资源"google_compute_subnetwork“中的”网络-具有私有-次要-ip-范围“:20: ip_cidr_range = var.pods_secondary_cidr_range
这些地址在我看来很好,除非我遗漏了一些明显的东西。还有什么会导致这个错误呢?
如果能对此提供任何帮助,我们将不胜感激。
编辑:
这不需要通过Cloud解决问题,这正是我需要复制的:
resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" {
name = var.vpc_subnet_name
ip_cidr_range = "10.51.0.0/20"
region = "europe-west2"
network = google_compute_network.custom-test.id
secondary_ip_range {
range_name = "services"
ip_cidr_range = "10.52.0.0/20"
}
secondary_ip_range {
range_name = "pods"
ip_cidr_range = "10.53.0.0/20"
}
}
resource "google_compute_network" "custom-test" {
name = "projectname-subnet-eu"
auto_create_subnetworks = false
}发布于 2022-05-16 09:48:59
你的子网有错误的CIDRS。如果您不确定它们应该如何,可以使用熔池子网函数为您的VPC提供正确的CIDR。例如:
> cidrsubnet("10.51.0.0/20", 4, 0)
"10.51.0.0/24"
> cidrsubnet("10.51.0.0/20", 4, 1)
"10.51.1.0/24"
> cidrsubnet("10.51.0.0/20", 4, 2)
"10.51.2.0/24"
> cidrsubnet("10.51.0.0/20", 4, 3)
"10.51.3.0/24"发布于 2022-05-19 14:26:04
若要查找可使用的有效CIDR地址,https://github.com/GoogleCloudPlatform/networking-tools-python/tree/main/tools/cidr
希望这能解决你的问题。
https://stackoverflow.com/questions/72232623
复制相似问题