【发布时间】:2023-04-06 06:32:01
【问题描述】:
在我尝试使用 terraform 创建子网时不断收到以下错误。使用 aws 控制台创建子网没有问题。有人可以帮我吗?
Error: error creating subnet: InvalidSubnet.Range: The CIDR '10.2.0.128/26' is invalid. │ status code: 400
Error: error creating subnet: InvalidSubnet.Range: The CIDR '10.2.0.64/26' is invalid. │ status code: 400
Error: error creating subnet: InvalidSubnet.Range: The CIDR '10.2.0.0/26' is invalid. │ status code: 400
我正在为 VPC 和子网使用低于 CIDR 范围
variable "cidr_block" {
default = "10.1.0.0/21"
description = "VPC CIDR Block"
type = string
}
variable "public_subnet_cidr_blocks" {
default = ["10.1.0.0/26","10.2.0.0/26","10.1.0.64/26","10.2.0.64/26","10.1.0.128/26","10.2.0.128/26"]
type = list
description = "List of public subnet CIDR blocks"
}
variable "private_subnet_cidr_blocks" {
default = ["10.3.0.0/25", "10.4.0.128/25", "10.3.0.128/25", "10.5.0.0/25", "10.4.0.0/25","10.5.0.128/25"]
type = list
description = "List of private subnet CIDR blocks"
}
【问题讨论】:
-
10.1.0.1/21仅涵盖地址范围10.1.0.1-10.1.7.254,但您正试图在此范围之外分配地址。我建议使用子网计算器。
标签: amazon-web-services terraform terraform-provider-aws amazon-vpc