hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.2k forks source link

[Bug]: Route table updating all the time whenever applying Terraform configuration changes #30023

Open krishanshamod opened 1 year ago

krishanshamod commented 1 year ago

Terraform Core Version

1.3.7

AWS Provider Version

4.38.0

Affected Resource(s)

aws_route_table

Expected Behavior

I'm using a NAT instance instead of a NAT gateway and I configured the route in the private route table using Terraform. All works fine.

Actual Behavior

But when I'm applying any kind of Terraform change, it's suggesting route table updates.

Relevant Error/Panic Output Snippet

# aws_route_table.private_route_table will be updated in-place
  ~ resource "aws_route_table" "private_route_table" {
        id               = "rtb-xxxxxxxxxxxx"
      ~ route            = [
          + {
              + carrier_gateway_id         = ""
              + cidr_block                 = "0.0.0.0/0"
              + core_network_arn           = ""
              + destination_prefix_list_id = ""
              + egress_only_gateway_id     = ""
              + gateway_id                 = ""
              + instance_id                = ""
              + ipv6_cidr_block            = ""
              + local_gateway_id           = ""
              + nat_gateway_id             = ""
              + network_interface_id       = "eni-xxxxxxxxxxxx"
              + transit_gateway_id         = ""
              + vpc_endpoint_id            = ""
              + vpc_peering_connection_id  = ""
            },
          - {
              - carrier_gateway_id         = ""
              - cidr_block                 = "0.0.0.0/0"
              - core_network_arn           = ""
              - destination_prefix_list_id = ""
              - egress_only_gateway_id     = ""
              - gateway_id                 = ""
              - instance_id                = "i-xxxxxxxxxxxx"
              - ipv6_cidr_block            = ""
              - local_gateway_id           = ""
              - nat_gateway_id             = ""
              - network_interface_id       = "eni-xxxxxxxxxxxx"
              - transit_gateway_id         = ""
              - vpc_endpoint_id            = ""
              - vpc_peering_connection_id  = ""
            },
        ]
        tags             = {
            "Name" = "private_route_table"
        }
        # (5 unchanged attributes hidden)
    }

Terraform Configuration Files

resource "aws_route_table" "private_route_table" {
  vpc_id = aws_vpc.main.id

  route {
    cidr_block           = "0.0.0.0/0"
    network_interface_id = aws_instance.nat_vm.primary_network_interface_id
  }

  tags = {
    Name = "private_route_table"
  }
}

Steps to Reproduce

That problem will be fixed when I add instance_id to the route but that attribute is a deprecated one.

Here's the code after I added that attribute.

resource "aws_route_table" "private_route_table" {
  vpc_id = aws_vpc.main.id

  route {
    cidr_block           = "0.0.0.0/0"
    instance_id          = aws_instance.nat_vm.id
    network_interface_id = aws_instance.nat_vm.primary_network_interface_id
  }

  tags = {
    Name = "private_route_table"
  }
}

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

ssadler commented 2 months ago

Any update on this? Is there a workaround?

jrandall commented 4 days ago

I believe this was fixed in https://github.com/hashicorp/terraform-provider-aws/pull/30804 and release in v5 of the provider.