fix(gcp): split custom-role permissions by scope#47
Merged
Conversation
The project-scoped google_project_iam_custom_role was failing to apply on single-project installs (no organization_id) with: Error: Permission accesscontextmanager.accessPolicies.get is not valid. Access Context Manager and Org Policy permissions are only includable in organisation-scoped custom roles — GCP rejects them in a project-scoped custom role because the underlying resources live at the organisation. Split custom_role_permissions into: - _common: project + org safe (24 permissions) - _org_only: accesscontextmanager.* + orgpolicy.* (6 permissions) The org-scoped role gets both via concat(); the project-scoped role gets only _common. Single-project installs have no VPC SC or org-policy data to read at project scope, so dropping these is functionally a no-op. Also adds an explicit depends_on to google_project_service.required on the project-scoped custom role to match the dependency pattern used by the SA / WIF pool / WIF provider in the same module, and avoids a fresh-project race where the role is created before iam.googleapis.com is enabled. docs/permissions.md flags the org-only permissions with an asterisk and a footnote explaining when they are silently omitted. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tim-thacker-nullify
approved these changes
Apr 30, 2026
4 tasks
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"with noorganization_id) installs of the GCP cloud connector were failing at apply withPermission accesscontextmanager.accessPolicies.get is not valid.because Access Context Manager and Org Policy permissions are only includable in organisation-scoped custom roles.custom_role_permissionsinto_common(project + org safe, 24 perms) and_org_only(accesscontextmanager.*+orgpolicy.*, 6 perms). The org-scoped role concats both; the project-scoped role uses only_common. Single-project installs have no VPC SC or org-policy data to read at project scope, so this is functionally a no-op for them.depends_on = [google_project_service.required]to the project-scopedgoogle_project_iam_custom_role, matching the dependency pattern already used by the SA / WIF pool / WIF provider in the same module. Closes a fresh-project race where the role could be created beforeiam.googleapis.comis enabled.docs/permissions.mdflags the org-only permissions with*and a footnote.Repro of the original failure
Test plan
terraform validatepasses forexamples/single-project,examples/folder,examples/organizationand the local single-project test rigterraform fmt -checkpasses on changed filesterraform-validate.yml) — covered by the workflow's existing matrixNotes