Closed michaellzc closed 11 months ago
The upgrade guide states that terraform_labels
is an output-only attribute. Is it possible to make the resource not forceCreate on change? I have a number of MIGs where this would be a burdensome interruption for essentially a no-op if this is truly output-only.
EDIT: I ended up updating state entries manually since this appears to be an output-only change. Leaving my jq
query here in case it helps others:
cat state.tfstate \
| jq '(.serial += 1) | (.resources[] | select(.type == "google_compute_instance_template").instances[].attributes) |= . + {terraform_labels: .labels}' \
>state.tfstate2
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.
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
1.5.6
1.6.3
Affected Resource(s)
ForceNew=true
on theterraform_labels
fieldTerraform Configuration Files
Debug Output
plan
apply
Panic Output
N/A
Expected Behavior
Actual Behavior
We are upgrading from v4 to v5, and I am aware of the new
terraform_labels
change https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/version_5_upgrade#providerAccording to
terraform plan
, the computedterraform_labels
field will be populated. Uponterraform apply
, we got an error complainingError: doesn't support update
.Steps to Reproduce
google_compute_instance_template
and apply it using v4 providerterraform_labels
Error: doesn't support update
.Important Factoids
References
google_compute_instance_template
is immutable. Hence other fields contain aForceNew=true
in the schema definition:https://github.com/hashicorp/terraform-provider-google/blob/3a7a8eb2282a112f92cbc16b1f4f143bde67a1f6/google/services/compute/resource_compute_instance_template.go#L156-L164
However,
terraform_labels
does not have this attribute, introduced in https://github.com/hashicorp/terraform-provider-google/commit/3e00cfbafa1ef13ebfd7e039bcec77407b824bfc#diff-ac874ea0db4bd5f5a83e2c2ed7f1dcb0514262d10a386b119e882986c2c58bd6R869-R873https://github.com/hashicorp/terraform-provider-google/blob/3a7a8eb2282a112f92cbc16b1f4f143bde67a1f6/google/services/compute/resource_compute_instance_template.go#L869-L875
The workaround is manually tainting all instances of
google_compute_instance_template
prior to runningterraform apply
during the upgrade; this will force a replacement.b/309602560