Show diff for computed nested labels fields when creating resources #2147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes hashicorp/terraform-provider-google#17756
Error
Resource
google_cloud_run_service
andgoogle_cloud_run_domain_mapping
have nested labels fieldsmetadata.0.labels
andmetadata.0.annotations
.In the CustomizeDiff function SetMetadataLabelsDiff,
SetNew
is applied on "metadata" field with the object includingterraform_labels
andeffective_labels
. It introduced two bugs.metadata.0.labels
andmetadata.0.annotations
fields don't appear in terraform planThis bug cannot be fixed with the similar way in Fix the bug for computed labels and annotations magic-modules#10182.
The reason is that
metadata.0.terraform_labels
andmetadat.0.effective_labels
fields cannot be set to computed due to a bug that SetNew doesn't work on nested fieldsin terraform sdk SetNew does not work on nested fields hashicorp/terraform-plugin-sdk#459
The solution to fix these two bugs in my mind is to move
terraform_labels
andeffective_labels
to root level in provider release 6.0.Before the release 6.0, the first bug can be fixed in this PR and I don't find an easy way to fix the second bug.
Release Note Template for Downstream PRs (will be copied)
Derived from GoogleCloudPlatform/magic-modules#10401