Score:0

How do I get rid of the deprecation warnings on my aws_route_table definitions?

cn flag

All of my route table definitions throw a deprecation warning during the plan/apply stages. I can't figure out how I should be defining my routes so that I stop getting these warnings.

Here's an example of one of my route table resources:

resource "aws_route_table" "rtb_public" {
  vpc_id = aws_vpc.app_vpc.id
  route = [
    {
      cidr_block                 = "0.0.0.0/0"
      gateway_id                 = aws_internet_gateway.app_igw.id
      egress_only_gateway_id     = ""
      instance_id                = ""
      ipv6_cidr_block            = null
      nat_gateway_id             = ""
      network_interface_id       = ""
      transit_gateway_id         = ""
      vpc_peering_connection_id  = ""
      carrier_gateway_id         = ""
      core_network_arn           = ""
      destination_prefix_list_id = ""
      local_gateway_id           = ""
      vpc_endpoint_id            = ""
    }
  ]
  tags = {
    Name = "${var.vpc_name}-rtb-public"
  }
}

This results in the following output from Terraform:

Warning: Argument is deprecated
...
Use network_interface_id instead

The docs mention that instance_id is deprecated. However, if I try to remove it from my routes, I get an error telling me instance_id is required.

In case it matters, here are the versions from my state file:

"version": 4,
"terraform_version": "1.3.9",
"serial": 83,
Score:0
cn flag

It turns out that all those attributes are only required on the route objects when the aws_route_table.route parameter is an array. Changing the route parameter to a single object allowed me to remove all of the unused object properties, like this:

resource "aws_route_table" "rtb_public" {
  vpc_id = aws_vpc.app_vpc.id
  route {
    cidr_block      = "0.0.0.0/0"
    gateway_id      = aws_internet_gateway.app_igw.id
    ipv6_cidr_block = null
  }
  tags = {
    Name = "${var.vpc_name}-rtb-public"
  }
}

This didn't work for me the first time because I'd mistakenly put an = after route.

ph flag
It seems like this argument is using the special legacy [Attributes as Blocks mode](https://developer.hashicorp.com/terraform/language/attr-as-blocks) for compatibility with quirks of older versions of Terraform. If the provider documentation for `route` didn't mention that then that's a documentation bug -- any argument using this legacy mode should be documented as such -- and so probably worth reporting in [the AWS provider repository](https://github.com/hashicorp/terraform-provider-aws).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.