【发布时间】:2021-12-14 01:22:17
【问题描述】:
对于 terraform 来说相对较新,目前正尝试在 AWS 中构建云基础设施。 当我使用资源 aws_route_table (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table)
的文档中的官方示例(稍有更改)时出现错误resource "aws_route_table" "prod-route-table" {
vpc_id = aws_vpc.prod-vpc.id
route = [{
# Route all Traffic to the internet gateway
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gw.id
},{
ipv6_cidr_block = "::/0"
gateway_id = aws_internet_gateway.gw.id
}]
}
我收到以下错误消息
Error: Incorrect attribute value type
│ Inappropriate value for attribute "route": element 0: attributes "carrier_gateway_id",
│ "destination_prefix_list_id", "egress_only_gateway_id", "instance_id", "ipv6_cidr_block",
│ "local_gateway_id", "nat_gateway_id", "network_interface_id", "transit_gateway_id", "vpc_endpoint_id",
│ and "vpc_peering_connection_id" are required.
添加所有这些属性可以解决错误,但是这会极大地破坏代码。 以不同的方式编写它(见下文)不会导致错误,terraform AWS 文档是否不正确,因为它们清楚地说明了第一种编写方式?
resource "aws_route_table" "prod-route-table" {
vpc_id = aws_vpc.prod-vpc.id
route {
# Route all Traffic to the internet gateway
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gw.id
}
route{
ipv6_cidr_block = "::/0"
gateway_id = aws_internet_gateway.gw.id
}
}
我正在使用 terraform v1.0.10 和 aws provider version = "3.63.0"
提前致谢
【问题讨论】:
标签: amazon-web-services terraform terraform-provider-aws