feat(gcp): warn on project-scope installs missing organization_id#49
Closed
tim-thacker-nullify wants to merge 1 commit into
Closed
feat(gcp): warn on project-scope installs missing organization_id#49tim-thacker-nullify wants to merge 1 commit into
tim-thacker-nullify wants to merge 1 commit into
Conversation
Adds a `check` block that emits a Terraform warning at plan/apply when `scope = "projects"` is used without `organization_id`. The install still succeeds — single-project is a valid POC mode — but the user is informed up-front that VPC Service Controls perimeters / access policies and organization policies will not appear in the inventory at this scope (those resources live at organisation scope; the corresponding GCP APIs return empty results when queried at project scope). `check` blocks (Terraform 1.5+) emit warnings without failing the plan, which is what we want here: the existing single-project example must continue to apply cleanly with no organization_id, just with a heads-up in the plan output. Co-Authored-By: Claude Opus 4.7 (1M context) <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
scope = \"projects\"and noorganization_id, the apply succeeds and they get a green console verify, but VPC Service Controls perimeters / access policies and organization policies silently never appear in their Nullify inventory — those resources live at the organisation level and the corresponding GCP APIs return empty results when queried at project scope.checkblock inmodules/nullify-gcp-integration/main.tfthat emits a warning in this exact configuration explaining what's not visible and how to enable it (setorganization_id, or switch toscope = \"organization\"/\"folder\").checkblocks (Terraform 1.5+, already required by the module) emit warnings without failing the plan, so legitimate single-project POC installs are unaffected — they just get a heads-up in the plan output.Why a
checkblock, not apreconditionThe existing
terraform_data.input_validationuses preconditions, which fail the plan. That's correct for the cases it covers (e.g.scope = \"folder\"withoutfolder_idcannot work). But here the install genuinely works — single-project is a documented POC mode (examples/single-project/) — we just want the user to know about the gap. A precondition would force every single-project user to either setorganization_idor pass a--varoverride, which is the wrong UX.Test plan
terraform validatepasses forexamples/single-project,examples/folder, andexamples/organizationagainst the modified moduleterraform fmt -check -recursivecleanterraform-validate.yml) green across the matrixNotes
checkcondition is only false whenscope == \"projects\" && organization_id == \"\").