networksecurity: ForceNew name+location on address_group (#17287)#56
Open
jbbqqf wants to merge 11 commits into
Open
networksecurity: ForceNew name+location on address_group (#17287)#56jbbqqf wants to merge 11 commits into
jbbqqf wants to merge 11 commits into
Conversation
…oogleCloudPlatform#17287) The AddressGroup name and location are URL parameters and the API does not support modifying them in place; changing either silently produces an inconsistent-after-apply result. Add immutable: true on both the organization-scoped (AddressGroup) and project-scoped (ProjectAddressGroup) parameters so Terraform plans a replacement instead of an in-place update. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Mark
nameandlocationURL parameters as immutable ongoogle_network_security_address_group(and the org-scoped equivalent), so the provider plans a replacement instead of an in-place update when either changes.Fixes hashicorp/terraform-provider-google#17287 — see hashicorp/terraform-provider-google#17287
Why
The Network Security Address Groups REST API uses
nameandlocationas URL path parameters; the underlyingUpdate(PATCH) endpoint cannot rename or relocate the resource. When a user changeslocation(orname), the current schema lets Terraform plan an in-place update, the PATCH succeeds against the old URL, and Terraform then reads back state from the new URL it expected — producing the inconsistent-after-apply error reported by users (and the maintainer-acknowledged fix in #17287).Marking both parameters
immutable: truein the mmv1 schema causes mmv1 to emitForceNew: true, which is what the resource has always needed.GCP API reference:
name+locationin URL)What changed
mmv1 YAML edits, two files:
Adds
immutable: trueto thenameandlocationURL parameters on both resources.Edge cases tested
ForceNew: trueis emitted onnameandlocationschema fields in the generatedresource_network_security_address_group.goRequired: true; withimmutable: truemmv1 emitsRequired: true, ForceNew: true(this is the same pattern already used byparenton the org-scoped resource and by every other URL param across mmv1).AddressGroup.yaml(org) andProjectAddressGroup.yaml(project, the one users hit viagoogle_network_security_address_group) get the fixnameorlocationmid-testmmv1/templates/terraform/examples/network_security_address_groups_*.tf.tmpl— none mutate name/location.Test protocol
immutable: true) are the most common modifier across mmv1 and require no code generation changes.Required: truewith noForceNew) and acknowledged by the maintainer in the issue. The "after" effect is mechanical: mmv1 always lowersimmutable: trueon aurl_param_onlyfield toForceNew: trueon the schema. Running a realapply ; change location ; applyon GCP would only re-prove what the code already shows; risk-of-regression is essentially zero.The author (a human) reviewed the diff against the generated Go in tpg main:
Both already follow the pattern of
parent(which hasimmutable: trueand emitsForceNew: true). This PR alignsnameandlocationwithparent.Resources
ForceNewis missing onlocation; subsequent commenters reported the same onname.Disclosure
This PR was implemented with assistance from Claude Code as part of a focused contribution batch on hand-written and mmv1 fixes. The diff is 4 lines of YAML; it was reviewed manually against the GCP REST API documentation (URL parameters cannot be renamed via PATCH) and against the generated Go schema in tpg main (which currently has
Required: truewith noForceNewon these fields, exactly matching the maintainer's diagnosis).The author (a human) reviewed the diff and the issue thread before opening this PR.