Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

AWS Route Table – Terraform | An argument named "gateway_id" is not expected here

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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."
    }
}

>Solution :

The gateway_id attribute must be inside the route block [1]

References:

  1. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table#route
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading