add send_secondary_ip_range_if_empty #7961
Merged
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.
part of hashicorp/terraform-provider-google#12824 and hashicorp/terraform-provider-google#17881
adds a virtual field to replace the need to set
secondary_ip_range = []
to removesecondary_ip_range
explicitly. The virtual field in combination withGetRawConfig().GetAttr("secondary_ip_range")
can let us detect when the user has intent to set to an empty list vs intending to let the backend manage the field.Normally, when removing an Optional+Computed field from config, Terraform will not produce a diff. The
sendSecondaryIpRangeIfEmptyDiff
checks if the new flag is set and then compares the config value with the state value usingGetRawConfig()
andGetOk
respectively.The actual update call is handled in a post_update custom code block.
This logic works with and without SchemaConfigModeAttr, allowing an upgrade path in 5.x before removing SchemaConfigModeAttr from
secondary_ip_range
in 6.0Release Note Template for Downstream PRs (will be copied)
Derived from GoogleCloudPlatform/magic-modules#11410