aiven / terraform-provider-aiven

Aiven Terraform Provider
https://registry.terraform.io/providers/aiven/aiven/latest/docs
MIT License
122 stars 68 forks source link

Persistent diff when removing the deprecated aiven_transit_gateway_vpc_attachment.peer_region field #1751

Closed shaunkillingbeck closed 5 days ago

shaunkillingbeck commented 4 weeks ago

What happened?

To comply with the instruction that aiven_transit_gateway_vpc_attachment.peer_region is deprecated, we removed the field from our terraform files. However every plan now shows the resource as changing i.e. peer_region = "[region]" -> null in each plan, even after applying the change.

resource "aiven_transit_gateway_vpc_attachment" "this" {
  for_each = local.vpc_attachments
  }

  vpc_id                  = each.value.vpc_id
  peer_cloud_account      = each.value.peer_cloud_account
  peer_vpc                = each.value.peer_vpc
  user_peer_network_cidrs = each.value.user_peer_network_cidrs
  # peer_region removed from configuration
}
  # aiven_transit_gateway_vpc_attachment.this["xxxxx"] will be updated in-place
  ~ resource "aiven_transit_gateway_vpc_attachment" "this" {
        id                      = "xxxxxxx"
      - peer_region             = "eu-west-1" -> null
        # (6 unchanged attributes hidden)
    }

What did you expect to happen?

We expected that removing the deprecated field would lead to no change in terraform plan (other than removing the deprecation warning)

What else do we need to know?

shaunkillingbeck commented 4 weeks ago

@Serpentiel would you be able to take a look at this? I think you deprecated the field originally so wondering if you have a better idea what is going on under the hood here

Serpentiel commented 4 weeks ago

Hey, @shaunkillingbeck! 👋

I'm afraid I'm no longer actively participating in the maintenance of this repository.

I'll mention @byashimov or @rriski for additional help, though.

As a quick fix, I could suggest you to set the field to null in your state manually. This should help with avoiding the problem until it's resolved.

shaunkillingbeck commented 3 weeks ago

Hey, @shaunkillingbeck! 👋

I'm afraid I'm no longer actively participating in the maintenance of this repository.

I'll mention @byashimov or @rriski for additional help, though.

As a quick fix, I could suggest you to set the field to null in your state manually. This should help with avoiding the problem until it's resolved.

Thanks @Serpentiel - @byashimov or @rriski thoughts on this? I had already tried the suggestion (set the field to null in the state) and it didn't seem to resolve the issue unfortunately, which makes me think the populated peer_region value is probably coming from the API and being compared to the null value in the configuration

byashimov commented 2 weeks ago

Hey @shaunkillingbeck thank you for you report, and sorry for the long response. Currently I'm trying to clarify this deprecation. It might be even not deprecated. So please ignore the message until it's fixed. Thanks!

byashimov commented 5 days ago

Hey. It turns out the field was mistakenly deprecated. Moreover, it is create-only. Please make sure you set the value back before the upgrade, as I had to mark it as ForceNew to fix this. Thank you!