Repository navigation
feat(0-bootstrap): gate compute.requireOsLogin by compliance regime - #293
Merged
Merged
Conversation
aghassemlouei
requested review from
Calvin-Cheng1,
LanceWray and
mgcarey-google
October 20, 2026 02:30
aghassemlouei
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
2 times, most recently
from
October 20, 2026 22:33
6d23940 to
a7b4413
Compare
aghassemlouei
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
from
October 20, 2026 22:57
a7b4413 to
fc2fa74
Compare
aghassemlouei
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
from
October 20, 2026 23:26
fc2fa74 to
f846e1c
Compare
aghassemlouei
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
3 times, most recently
from
October 21, 2026 00:18
8a6a81b to
e02c951
Compare
aghassemlouei
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
3 times, most recently
from
October 22, 2026 02:14
986aca1 to
8e5b8d2
Compare
Calvin-Cheng1
requested changes
Oct 22, 2026
Calvin-Cheng1
left a comment
Collaborator
There was a problem hiding this comment.
Suggestions here:
-
fast/stages-aw/0-bootstrap/organization.tf(lines 111 and 115–127)- Issue: Wrapping
file(...),templatefile(...), andyamldecode(...)insidetry({ for k, v in ... : k => v }, {})silently swallows any YAML syntax error or invalid template variable indata/org-policies/ordata/custom-org-policies/and replaces the entire file with{}. If a policy file is malformed,terraform planwill not fail andterraform applywill destroy every organization policy defined in that file. - Fix: Revert
organization.tfto leaveyamldecode(file(...))andyamldecode(templatefile(...))unwrapped. Terraform'smerge(...)natively handles both empty maps ({}) andnullresults from empty YAML templates (such aslb_policy.yamlunderFEDRAMP_MODERATE), while still failing fast on invalid YAML or template syntax.
- Issue: Wrapping
-
fast/stages-aw/0-bootstrap/import.sh(lines 57–60)- Issue:
import.shchecks whether a policy is managed usinggrep -rq "^${constraint_name}:" ./data/org-policies/ ./data/custom-org-policies/. Becausecompute.requireOsLogin:still appears at column 0 in the unrendereddata/custom-org-policies/compute_policy.yamltemplate,import.shmatches it even whenregimeisIL4orIL5and stages animportblock formodule.organization.google_org_policy_policy.default["compute.requireOsLogin"]. If the organization already hascompute.requireOsLoginset,terraform applyinimport.shwill fail withConfiguration for import target does not exist. - Fix: Query the evaluated policy keys from Terraform before the loop (
declared_policies=$(echo 'keys(local.org_policies)' | terraform console 2>/dev/null)) and checkecho "${declared_policies}" | grep -qF "\"${constraint_name}\""instead of runninggrepagainst the unrendered YAML templates.
- Issue:
-
fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml(line 16)- Issue: The condition checks
!contains(["IL4", "IL5", "ASSURED_WORKLOADS_IL4", "ASSURED_WORKLOADS_IL5"], regime), but"ASSURED_WORKLOADS_IL4"and"ASSURED_WORKLOADS_IL5"are not valid GCP Assured WorkloadsComplianceRegimeenum values and do not exist invar.regime_mapping(variables.tflines 351–382). - Fix: Simplify the condition to
%{ if !contains(["IL4", "IL5"], regime) ~}.
- Issue: The condition checks
-
fast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yaml(lines 74–83) &fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml(lines 16–22)- Issue: The 9-line descriptive comment block for
compute.requireOsLoginwas left behind indata/org-policies/compute_policy.yamlwithout a rule underneath it, unlikelb_policy.yaml,networking_policy.yaml, andplatform_policy.yamlindata/custom-org-policies/, which keep the comment block with the templated rule.data/custom-org-policies/compute_policy.yamlis also missing a trailing newline at EOF. - Fix: Move the 9-line comment block for
compute.requireOsLoginfromdata/org-policies/compute_policy.yamlintodata/custom-org-policies/compute_policy.yamldirectly abovecompute.requireOsLogin:, and add a trailing newline at the end ofdata/custom-org-policies/compute_policy.yaml.
- Issue: The 9-line descriptive comment block for
aghassemlouei
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
2 times, most recently
from
October 23, 2026 12:46
b4b9a27 to
414b717
Compare
Member
Author
|
Addressed in 2722d43:
Appreciate you flagging this and apologies for missing it! |
aghassemlouei
added a commit
that referenced
this pull request
Oct 26, 2026
#293 (review) - fast/stages-aw/0-bootstrap/organization.tf: remove try() wrappers around yamldecode(file(...)) and yamldecode(templatefile(...)) so malformed YAML or template syntax fails fast (@Calvin-Cheng1) (item 1) - fast/stages-aw/0-bootstrap/import.sh: query evaluated keys(local.org_policies) via terraform console instead of grepping unrendered YAML templates (@Calvin-Cheng1) (item 2) - fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml: simplify regime condition to !contains(["IL4", "IL5"], regime) (@Calvin-Cheng1) (item 3) - fast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yaml, fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml: move the compute.requireOsLogin comment block into custom-org-policies and ensure a trailing newline (@Calvin-Cheng1) (item 4)
aghassemlouei
enabled auto-merge (squash)
October 26, 2026 20:06
Calvin-Cheng1
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
from
October 27, 2026 05:13
973460d to
2abd717
Compare
Calvin-Cheng1
pushed a commit
that referenced
this pull request
Oct 27, 2026
#293 (review) - fast/stages-aw/0-bootstrap/organization.tf: remove try() wrappers around yamldecode(file(...)) and yamldecode(templatefile(...)) so malformed YAML or template syntax fails fast (@Calvin-Cheng1) (item 1) - fast/stages-aw/0-bootstrap/import.sh: query evaluated keys(local.org_policies) via terraform console instead of grepping unrendered YAML templates (@Calvin-Cheng1) (item 2) - fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml: simplify regime condition to !contains(["IL4", "IL5"], regime) (@Calvin-Cheng1) (item 3) - fast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yaml, fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml: move the compute.requireOsLogin comment block into custom-org-policies and ensure a trailing newline (@Calvin-Cheng1) (item 4)
Calvin-Cheng1
previously approved these changes
Oct 27, 2026
aghassemlouei
added a commit
that referenced
this pull request
Oct 28, 2026
#293 (review) - fast/stages-aw/0-bootstrap/organization.tf: remove try() wrappers around yamldecode(file(...)) and yamldecode(templatefile(...)) so malformed YAML or template syntax fails fast (@Calvin-Cheng1) (item 1) - fast/stages-aw/0-bootstrap/import.sh: query evaluated keys(local.org_policies) via terraform console instead of grepping unrendered YAML templates (@Calvin-Cheng1) (item 2) - fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml: simplify regime condition to !contains(["IL4", "IL5"], regime) (@Calvin-Cheng1) (item 3) - fast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yaml, fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml: move the compute.requireOsLogin comment block into custom-org-policies and ensure a trailing newline (@Calvin-Cheng1) (item 4)
aghassemlouei
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
from
October 28, 2026 04:09
2abd717 to
a558d48
Compare
15 of 19 tasks
#293 (review) - fast/stages-aw/0-bootstrap/organization.tf: remove try() wrappers around yamldecode(file(...)) and yamldecode(templatefile(...)) so malformed YAML or template syntax fails fast (@Calvin-Cheng1) (item 1) - fast/stages-aw/0-bootstrap/import.sh: query evaluated keys(local.org_policies) via terraform console instead of grepping unrendered YAML templates (@Calvin-Cheng1) (item 2) - fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml: simplify regime condition to !contains(["IL4", "IL5"], regime) (@Calvin-Cheng1) (item 3) - fast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yaml, fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml: move the compute.requireOsLogin comment block into custom-org-policies and ensure a trailing newline (@Calvin-Cheng1) (item 4)
aghassemlouei
force-pushed
the
feat/bootstrap-regime-conditional-oslogin
branch
from
October 28, 2026 04:16
a558d48 to
103955e
Compare
Calvin-Cheng1
approved these changes
Oct 28, 2026
Merged
18 of 19 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.
Description
compute.requireOsLoginfrom staticfast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yamlinto regime-awarefast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yamlso that OS Login is enforced for FedRAMP Moderate, FedRAMP High, and US Region Restricted workloads while skipped for IL4 and IL5 workloads where Assured Workloads manages OS Login directly, fixing [Feature Request]Customize Org Policy Enforcement Based on Regime Setting #197.yamldecode(templatefile(...))infast/stages-aw/0-bootstrap/organization.tfwithtry({ for k, v in ... : k => v }, {})so custom organization policy templates that render an empty map under excluded regimes evaluate cleanly duringterraform plan.Fixes #197
Type of Change
Deployment & Compliance Impact
Checklist
Code Quality & Reusability
modules/orfast/stages-aw/can be leveraged for this change.docs/naming-convention.md.Documentation
README.mdof the modified module or blueprint.Security
Testing
Testing Performed
bash tools/run_tests.sh(all Python unit tests, shell syntax checks, shell unit tests, and CodeQL AST checks pass).