我正在尝试通过 terraform 创建一个简单的 AWS_ALB,我创建了一个带有公共子网和私有子网的单独 VPC,但是 ALB 创建给了我 invalidSubnet 错误
resource "aws_alb" "test" {
name = "test-alb-tf"
internal = false
security_groups = ["sg-0385b126e18d3ca67"]
subnets = ["192.168.11.0/24"]
}
公共子网创建如下
{
"MapPublicIpOnLaunch": true,
"AvailabilityZoneId": "use1-az2",
"Tags": [
{
"Value": "staging",
"Key": "Environment"
},
{
"Value": "secure-public-us-east-1a",
"Key": "Name"
},
{
"Value": "true",
"Key": "Terraform"
}
],
"AvailableIpAddressCount": 250,
"DefaultForAz": false,
"SubnetArn": "arn:aws:ec2:us-east-1:041840987519:subnet/subnet-03757baf0df052c07",
"Ipv6CidrBlockAssociationSet": [],
"VpcId": "vpc-00689d5ff034a0c99",
"State": "available",
"AvailabilityZone": "us-east-1a",
"SubnetId": "subnet-03757baf0df052c07",
"OwnerId": "041840987519",
"CidrBlock": "192.168.11.0/24",
"AssignIpv6AddressOnCreation": false
},
这就是 terraform 计划显示的内容
# aws_alb.test will be created
+ resource "aws_alb" "test" {
+ arn = (known after apply)
+ arn_suffix = (known after apply)
+ dns_name = (known after apply)
+ enable_deletion_protection = false
+ enable_http2 = true
+ id = (known after apply)
+ idle_timeout = 60
+ internal = false
+ ip_address_type = (known after apply)
+ load_balancer_type = "application"
+ name = "test-alb-tf"
+ security_groups = [
+ "sg-0385b126e18d3ca67",
]
+ subnets = [
+ "192.168.11.0/24",
]
+ vpc_id = (known after apply)
+ zone_id = (known after apply)
+ subnet_mapping {
+ allocation_id = (known after apply)
+ subnet_id = (known after apply)
}
}
这是我得到的错误
Error: Error creating application Load Balancer: InvalidSubnet: The subnet ID '192.168.11.0/24' is not valid
status code: 400, request id: 5521ae30-dc0b-4f4c-ae89-47eb729126c7
任何人都知道我错过了什么