1

Running terraform v1.0.9 with AWS plugin v3.63.0 on a mac

Following hashicorp instructions for creating a route table (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table), but getting the following error:

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.

Here is my main.tf:

provider "aws" {
  region = "us-east-1"
}

resource "aws_vpc" "my-test-vpc" {
  cidr_block = "10.0.0.0/16"
  tags = {
    Name = "my-test-vpc"
  }
}

resource "aws_internet_gateway" "gw" {
  vpc_id = aws_vpc.my-test-vpc.id
}

resource "aws_route_table" "prod-route-table" {
  vpc_id = aws_vpc.my-test-vpc.id

  route = [
    {
      cidr_block = "0.0.0.0/0"
      gateway_id = aws_internet_gateway.gw.id
    }
  ]

  tags = {
    Name = "production"
  }
}
Y Pant
  • 53
  • 7
  • 1
    IPV6 IPs are globally unique and thus public by default - it's probably erroring as you're trying to assign a regular internet gateway to an IPV6 CIDR block; does removing that block work? The guide uses an egress-only IG, not a regular one. – Ermiya Eskandary Oct 17 '21 at 16:18
  • @ErmiyaEskandary - it does not help – Y Pant Oct 17 '21 at 17:18
  • So removing the entire IPV6 CIDR block doesn't fix it? If so, then edit your question to remove it to include the [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Ermiya Eskandary Oct 17 '21 at 17:58

1 Answers1

0

I have run into something similar, without getting to the bottom of the root cause, so this is not the best possible answer, but moving the route out into its own explicit resource works for me:

resource "aws_route_table" "prod-route-table" {
  vpc_id = aws_vpc.my-test-vpc.id

  tags = {
    Name = "production"
  }
}

resource "aws_route" "prod-route-igw" {
  route_table_id            = aws_route_table.prod-route-table.id
  destination_cidr_block    = "0.0.0.0/0"
  gateway_id                = aws_internet_gateway.gw.id
  depends_on                = [aws_route_table.prod-route-table]
}
clockworknet
  • 2,736
  • 1
  • 15
  • 19