Terraform wants to replace many resources because it detects that null != ""

I’m not sure what is causing this, I suspect that is that I upgraded from terraform 0.13.1 to 0.13.5. When I do terraform plan it says that it has to replace resource "aws_route_table" "vpc_route_table" because the route array is different but the only difference reported is that according to terraform is that there are some attributes in each route that used to be "" (empty string) and now they are null.

route            = [
          - {
              - cidr_block                = ""
              - egress_only_gateway_id    = ""
              - gateway_id                = "igw-xxxx"
              - instance_id               = ""
              - ipv6_cidr_block           = ""
              - nat_gateway_id            = ""
              - network_interface_id      = ""
              - transit_gateway_id        = ""
              - vpc_peering_connection_id = ""
          + {
              + cidr_block                = ""
              + egress_only_gateway_id    = null
              + gateway_id                = "igw-xxxx"
              + instance_id               = null
              + ipv6_cidr_block           = null
              + nat_gateway_id            = null
              + network_interface_id      = null
              + transit_gateway_id        = null
              + vpc_peering_connection_id = null

So, why is this happening? Is there anything I can do to prevent this in the future? and is there anyway to ignore those changes (I mean for this specific case “” == null , I believe)

Hi @ecerulm,

This seems like something that was more likely to be caused by a provider upgrade rather than a Terraform upgrade. Did you happen to also upgrade the AWS provider at the same time?

It is possible that this sort of change could result from a bug fix to Terraform Core, if something was not being compared correctly before, but AFAIK Terraform has been treating"" as different to null since Terraform 0.12 (which is the release that introduced null), and so that’s why I’m suspecting that it may be a change of behavior in the provider or in the provider SDK.

If we can narrow down exactly what caused this change in behavior then I may have a better suggestion, but for now I think the only general idea I have is to change the configuration to match the prior state, by writing out the empty string values of these arguments explicitly:

  gateway_id = ""
  # etc

Not ideal by any means, so I’m hoping we can find a better solution by narrowing down the cause.