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.83k stars 9.18k forks source link

[Bug]: route tables shows a diff for empty entries #31158

Closed heshammekky-sc closed 1 year ago

heshammekky-sc commented 1 year ago

Terraform Core Version

1.4.6

AWS Provider Version

4.37.0

Affected Resource(s)

aws_route_table

Expected Behavior

Right now, we have a route table entry (a route in aws_route_table) that looks like this

  route {
    ipv6_cidr_block           = "::/0"
    gateway_id                = <gateway-id>
    egress_only_gateway_id    = ""
    nat_gateway_id            = ""
    network_interface_id      = ""
    transit_gateway_id        = ""
    vpc_peering_connection_id = ""
  }

The route table contains other entries that are similar. When we add a new route entry, ideally we should see one new entry added to the route table. However, we see all entries are removed and re-added because we are missing some of the fields with empty string (e.g. instance_id, cidr_block or some other field).

When we try to add all these entries to get a clean diff output, it reject cidr_block = "" because it validates it against being a valid CIDR block.

An ideal configuration would be something like this where we only define the entries we can about in a route, and the rest is actually optional.

  route {
    ipv6_cidr_block           = "::/0"
    gateway_id                = <gateway-id>
  }

Actual Behavior

The actual behavior we observe is that all route table entries are deleted and re-added. In addition, we cannot pass cidr_block = "" to get a clean diff output, and we must define all empty entries to get the desired output which is not possible in this case.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

N/A

Steps to Reproduce

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

ewbankkit commented 1 year ago

@heshammekkysc Thanks for raising this issue. It has already been noticed in #17198. I'm going to close this one as a duplicate so that we can concentrate discussion in the linked issue. Please add any additional comments there.

ewbankkit commented 1 year ago

Following the merge of https://github.com/hashicorp/terraform-provider-aws/pull/30804 we should be able to address this for the upcoming v5.0.0 release of the Terraform AWS Provider.

heshammekky-sc commented 1 year ago

Thank you. Would that address the need of having to specify all the empty entries in the route? This didn't come across from the discussion in the other issue.

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.