I'm encountering an error while creating a route table in Terraform for AWS. My code looks correct, but I am receiving the following error:
Error: Incorrect attribute value type
on main.tf.json line 110, in resource.aws_route_table.public_rt:
110: "route": [
111: {
112: "cidr_block": "0.0.0.0/0",
113: "gateway_id": "${aws_internet_gateway.main_igw.id}"
114: }
115: ],
Inappropriate value for attribute "route": element 0: attributes "carrier_gateway_id", "core_network_arn", "destination_prefix_list_id", "egress_only_gateway_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.
- Context: I'm trying to configure a route table for a VPC in AWS with an associated Internet Gateway. Here's the code for the aws_route_table resource in my Terraform file
"aws_route_table": {
"public_rt": {
"vpc_id": "${var.vpc_id}",
"route": [
{
"cidr_block": "0.0.0.0/0",
"gateway_id": "${aws_internet_gateway.main_igw.id}"
}
],
"tags": {
"Name": "Public Route Table"
},
"depends_on": [
"aws_internet_gateway.main_igw"
]
}
}
- Additional Details:
I am defining an Internet Gateway separately in the same configuration. I get the error mentioned when trying to apply this code.
- Question:
What could be the cause of this error, and how can I fix the route configuration for AWS in this case? Should I add additional attributes to the route, or is it an issue related to the AWS provider version in Terraform?
Thanks for your help!