Hi,
I am new to terraform, not sure if this is bug with terraform, aws or I am missing something here.
My versions:
terraform v0.12.20
provider.aws v2.47.0
OS Ubuntu 18.04.3
I am using this piece of code to create aws_route_table resource:
resource “aws_route_table” “public” {
vpc_id = “{aws_vpc.main.id}"
route = {
cidr_block = "0.0.0.0/0"
gateway_id = "{aws_internet_gateway.igw.id}”
}
}
Following the guidance from 0.12 version syntax, I had to change vpc_id and gateway_id without dollar sign, quotes and parenthesis. This worked fine not just with aws_route_table resource but with other resources too. The problem I see is for the route section of the code. I tried these variations of code but terraform plan gives me one or other error.
Code variations for route section:
route = {
cidr_block = “0.0.0.0/0”
gateway_id = aws_internet_gateway.igw.id
}
terraform plan result:
Error: Incorrect attribute value type
on mainvpc.tf line 91, in resource “aws_route_table” “public”:
91: route = {
92: cidr_block = “0.0.0.0/0”
93: gateway_id = aws_internet_gateway.igw.id
94: }
Inappropriate value for attribute “route”: set of object required.
route = [
cidr_block = “0.0.0.0/0”
gateway_id = aws_internet_gateway.igw.id
]
terraform plan result:
Error: Missing item separator
on mainvpc.tf line 92, in resource “aws_route_table” “public”:
91:
92: cidr_block = “0.0.0.0/0”
Expected a comma to mark the beginning of the next item.
route = [
cidr_block = “0.0.0.0/0”,
gateway_id = aws_internet_gateway.igw.id
]
terraform plan result:
Error: Missing item separator
on mainvpc.tf line 92, in resource “aws_route_table” “public”:
91:
92: cidr_block = “0.0.0.0/0”,
Expected a comma to mark the beginning of the next item.
route = [
cidr_block , “0.0.0.0/0”,
gateway_id = aws_internet_gateway.igw.id
]
terraform plan result:
Error: Missing item separator
on mainvpc.tf line 93, in resource “aws_route_table” “public”:
91:
92:
93: gateway_id = aws_internet_gateway.igw.id
Expected a comma to mark the beginning of the next item.
route = [
cidr_block , “0.0.0.0/0”,
gateway_id , aws_internet_gateway.igw.id
]
terraform plan result:
Error: Invalid reference
on mainvpc.tf line 93, in resource “aws_route_table” “public”:
93: gateway_id , aws_internet_gateway.igw.id
A reference to a resource type must be followed by at least one attribute
access, specifying the resource name.
Can you please have look at this to determine what would be the correct code/syntax in this case? To be honest, I wouldn’t qualify to call it a bug but ran out of online help for this issue so thought it may be one.
Thanks in advance.
Regards,
Adil