I have an internet gateway and two subnets (public and private). While i can attach my internet gateway to the public one, i can't on the private one. I add this line in the code:
gateway_id = aws_internet_gateway.wally_jeropa_igw.id
but i have this error:
An argument named "gateway_id" is not expected here.
This is my IGW
resource "aws_internet_gateway" "wally_jeropa_igw" {
vpc_id = aws_vpc.wally_jeropa.id
tags = {
Name = "Testn IGW"
}
}
Public subnet
resource "aws_route_table" "wally_jeropa_vpc_public_route_table" {
vpc_id = aws_vpc.wally_jeropa.id
gateway_id = aws_internet_gateway.wally_jeropa_igw.id
route {
cidr_block = "0.0.0.0/0"
}
tags = {
Name = "Public Subnet Route Table."
}
}
Private subnet
resource "aws_route_table" "wally_jeropa_vpc_private_route_table" {
vpc_id = aws_vpc.wally_jeropa.id
gateway_id = aws_internet_gateway.wally_jeropa_igw.id
tags = {
Name = "Private Subnet Route Table."
}
}
CodePudding user response:
The gateway_id
attribute must be inside the route block [1]
References: