hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.34k stars 1.74k forks source link

Make mtu in google_compute_network updatable #8091

Open bharathkkb opened 3 years ago

bharathkkb commented 3 years ago

Community Note

Terraform Version

Affected Resource(s)

Terraform Configuration Files

https://github.com/terraform-google-modules/terraform-google-network/pull/221#issuecomment-752152710

Debug Output

Panic Output

Expected Behavior

I am able to update the MTU field

Actual Behavior

Delete recreate due to field being set as ForceNew

Steps to Reproduce

  1. terraform apply

Important Factoids

I am able to update network via a patch operation

curl --request PATCH \
  'https://compute.googleapis.com/compute/v1/projects/test-project/global/networks/test-vpc \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"mtu":1500}' \
  --compressed

References

chilversc commented 1 year ago

For further reference, this is officially supported by the API and is documented: https://cloud.google.com/vpc/docs/change-mtu-vpc-network#gcloud

The main issue to note according to the docs is that any VMs using the network should first be stopped before updating the MTU. If supporting an in-place update of the MTU the Terraform docs for google_compute_network.mtu should call out this issue. This might be a valid reason NOT to support an in-place update of the MTU as Terraform cannot easily manage this life-cycle of stopping and starting the VMs using the network. Though if this is the case, the provider should still document why an in-place update is not permitted and link to the relevent docs on how to update it by hand.

As a workaround you can first update the MTU by hand (e.g. by using gcloud compute networks update NETWORK --mtu=MTU), then update the MTU in Terraform to match and refresh the state.

ScottSuarez commented 7 months ago

I agree we likely should not support this field if we need to operate on another resource for support. Slating this issue for retriage