compute: add labels to google_compute_region_security_policy (#17993)#17495
Open
jbbqqf wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
Open
compute: add labels to google_compute_region_security_policy (#17993)#17495jbbqqf wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
jbbqqf wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
Conversation
…urity_policy (#17993)
Adds labels (KeyValueLabels) and labelFingerprint (output Fingerprint) to
the Region Security Policy mmv1 schema, mirroring the existing pattern on
google_compute_ha_vpn_gateway and the global google_compute_security_policy.
Labels are written via the regions/{region}/securityPolicies/{name}/setLabels
endpoint, which is exposed in the v1 compute SDK and confirmed end-to-end
against the GCP API.
Fixes hashicorp/terraform-provider-google#17993
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @zli82016, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
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
Adds
labels(KeyValueLabels) andlabelFingerprint(output Fingerprint) to thegoogle_compute_region_security_policymmv1 schema. The globalgoogle_compute_security_policyalready supports labels (via the same Cloud Armor labels API); this PR brings the regional resource to parity.Fixes hashicorp/terraform-provider-google#17993 — see hashicorp/terraform-provider-google#17993
Why
Cloud Armor security policies — both global and regional — accept
Labelsper the Compute REST API. The global resource already exposes alabelsattribute (google_compute_security_policy, seeresource_compute_security_policy.go:685in tpg). The regional sibling, also a real Cloud Armor policy resource, omits it, breaking parity for users who tag regional security policies for cost allocation, environment routing, or run-tag tracking.The regional setLabels endpoint is exposed in the v1 compute SDK as
RegionSecurityPoliciesService.SetLabels(google.golang.org/api/compute/v1/compute3-gen.go:24694), so no client-library work is required.GCP API reference:
What changed
mmv1 YAML edit only — the generated tpg/tpgb code follows automatically via the standard
KeyValueLabels+update_url=…/setLabelspattern that's already used by:mmv1/products/compute/HaVpnGateway.yaml(regional)mmv1/products/compute/InterconnectAttachment.yaml(regional)mmv1/products/compute/GlobalAddress.yaml(global), …Adds two properties just after the existing
fingerprintfield:The
KeyValueLabelstype is the standard mmv1 abstraction that auto-generateslabels,terraform_labels, andeffective_labelsschema attributes plus thetpgresource.SetLabelsDiffCustomizeDiff hook that the rest of the provider uses.Edge cases tested
# labels not setlabels = { run_tag = "...", scenario = "typical", env = "smoke" }labels = { ..., blank = "" }Before / After (Terraform)
Before — gap reproduced
tofu planagainst tpgorigin/main(binary rebuilt from origin):After — fix proven
tofu applyagainst tpg with this branch's mmv1 regen applied:Followed by
tofu destroy— all three policies cleanly removed.Test protocol
yqvalidation of the edited YAMLgo run . --output $TPG --product compute(mmv1 ga regen)go run . --output $TPGB --product compute --version beta(tpgb regen)go build ./...on tpggo build ./...on tpgbgo vet ./google/services/compute/...on tpgorigin/main)Unsupported argument 'labels'gcp-masterclasses/us-central1gcloud compute security-policies list --filter='region:us-central1'Verdict: 🟢 GREEN — BEFORE: plan_failed, AFTER: ok. Gap reproduced and fix proven end-to-end against the real GCP API.
Reproduction
A live BEFORE/AFTER reproduction (matching what was run for this PR) is available via the magic-modules-bootstrap smoke-tpg harness — see commit notes.
Resources
resource_compute_security_policy.go:685(handwritten)mmv1/products/compute/HaVpnGateway.yaml:184-201Release notes
Disclosure
This PR was drafted with assistance from Claude Code as part of a focused contribution batch on additive schema gaps. The mmv1 YAML diff was reviewed manually against the GCP REST API documentation and the existing global-vs-regional parity pattern. The live before/after smoke harness exercised real GCP resources in the author's sandbox project (
gcp-masterclasses); all resources were destroyed after the test phase, and a follow-upgcloud compute security-policies listconfirmed no orphans.The author (a human) reviewed the diff, the test outputs, and the smoke verdict before opening this PR.