Skip to content

feat(0-bootstrap): gate compute.requireOsLogin by compliance regime - #293

Merged
aghassemlouei merged 2 commits into
mainfrom
feat/bootstrap-regime-conditional-oslogin
Oct 28, 2026
Merged

aghassemlouei merged 2 commits into
mainfrom
feat/bootstrap-regime-conditional-oslogin

Conversation

@aghassemlouei

@aghassemlouei aghassemlouei commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Description

  • Move compute.requireOsLogin from static fast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yaml into regime-aware fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml so 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.
  • Guard yamldecode(templatefile(...)) in fast/stages-aw/0-bootstrap/organization.tf with try({ for k, v in ... : k => v }, {}) so custom organization policy templates that render an empty map under excluded regimes evaluate cleanly during terraform plan.

Fixes #197

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Deployment & Compliance Impact

  • Applicable Regimes:
    • US Region Restricted (e.g., Access Policy constraint)
    • FedRAMP Moderate
    • FedRAMP High
    • DoD IL4
    • DoD IL5
    • General / All
  • NIST 800-53r5 Controls: SC-7, SC-12, SC-13, SC-28, AC-2, AC-3, AC-6, CM-2, CM-6

Checklist

Code Quality & Reusability

  • My code adheres to the Maximize Reusability principle. I have not redefined common elements and have reused existing base configurations and modules where possible.
  • I have checked that no existing module or configuration in modules/ or fast/stages-aw/ can be leveraged for this change.
  • My code follows the established naming conventions outlined in docs/naming-convention.md.

Documentation

  • I have updated the README.md of the modified module or blueprint.
  • I have added/updated documentation for inputs (variables) and outputs.

Security

  • My change adheres to GCP security best practices and the principle of least privilege.
  • I have ensured compliance with the targeted regime (FedRAMP Moderate, FedRAMP High, IL4, IL5, etc.).

Testing

  • I have tested my changes locally.
  • I have included details of my testing in this PR.

Testing Performed

  • Executed bash tools/run_tests.sh (all Python unit tests, shell syntax checks, shell unit tests, and CodeQL AST checks pass).

@aghassemlouei aghassemlouei added Enhancement New feature or request Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Status - Ready for Review labels Oct 20, 2026
@github-actions github-actions Bot added the Scope - Fast Related to Fabric FAST deployment stages in the fast directory label Oct 20, 2026
@aghassemlouei
aghassemlouei force-pushed the feat/bootstrap-regime-conditional-oslogin branch 2 times, most recently from 6d23940 to a7b4413 Compare October 20, 2026 22:33
@aghassemlouei aghassemlouei added Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Framework - IL4 DoD Impact Level 4 (IL4) compliance regime and controls Framework - IL5 DoD Impact Level 5 (IL5) compliance regime and controls Framework - FedRAMP Moderate FedRAMP Moderate compliance regime and controls Framework - FedRAMP High FedRAMP High compliance regime and controls Scope - Stage 0 and removed Fast labels Oct 20, 2026
@aghassemlouei
aghassemlouei force-pushed the feat/bootstrap-regime-conditional-oslogin branch from a7b4413 to fc2fa74 Compare October 20, 2026 22:57
@aghassemlouei
aghassemlouei force-pushed the feat/bootstrap-regime-conditional-oslogin branch from fc2fa74 to f846e1c Compare October 20, 2026 23:26
@aghassemlouei aghassemlouei removed Framework - IL4 DoD Impact Level 4 (IL4) compliance regime and controls Framework - IL5 DoD Impact Level 5 (IL5) compliance regime and controls Framework - FedRAMP Moderate FedRAMP Moderate compliance regime and controls Framework - FedRAMP High FedRAMP High compliance regime and controls labels Oct 20, 2026
@aghassemlouei
aghassemlouei force-pushed the feat/bootstrap-regime-conditional-oslogin branch 3 times, most recently from 8a6a81b to e02c951 Compare October 21, 2026 00:18
@aghassemlouei
aghassemlouei force-pushed the feat/bootstrap-regime-conditional-oslogin branch 3 times, most recently from 986aca1 to 8e5b8d2 Compare October 22, 2026 02:14

@Calvin-Cheng1 Calvin-Cheng1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions here:

  1. fast/stages-aw/0-bootstrap/organization.tf (lines 111 and 115–127)

    • Issue: Wrapping file(...), templatefile(...), and yamldecode(...) inside try({ for k, v in ... : k => v }, {}) silently swallows any YAML syntax error or invalid template variable in data/org-policies/ or data/custom-org-policies/ and replaces the entire file with {}. If a policy file is malformed, terraform plan will not fail and terraform apply will destroy every organization policy defined in that file.
    • Fix: Revert organization.tf to leave yamldecode(file(...)) and yamldecode(templatefile(...)) unwrapped. Terraform's merge(...) natively handles both empty maps ({}) and null results from empty YAML templates (such as lb_policy.yaml under FEDRAMP_MODERATE), while still failing fast on invalid YAML or template syntax.
  2. fast/stages-aw/0-bootstrap/import.sh (lines 57–60)

    • Issue: import.sh checks whether a policy is managed using grep -rq "^${constraint_name}:" ./data/org-policies/ ./data/custom-org-policies/. Because compute.requireOsLogin: still appears at column 0 in the unrendered data/custom-org-policies/compute_policy.yaml template, import.sh matches it even when regime is IL4 or IL5 and stages an import block for module.organization.google_org_policy_policy.default["compute.requireOsLogin"]. If the organization already has compute.requireOsLogin set, terraform apply in import.sh will fail with Configuration 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 check echo "${declared_policies}" | grep -qF "\"${constraint_name}\"" instead of running grep against the unrendered YAML templates.
  3. 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 Workloads ComplianceRegime enum values and do not exist in var.regime_mapping (variables.tf lines 351–382).
    • Fix: Simplify the condition to %{ if !contains(["IL4", "IL5"], regime) ~}.
  4. 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.requireOsLogin was left behind in data/org-policies/compute_policy.yaml without a rule underneath it, unlike lb_policy.yaml, networking_policy.yaml, and platform_policy.yaml in data/custom-org-policies/, which keep the comment block with the templated rule. data/custom-org-policies/compute_policy.yaml is also missing a trailing newline at EOF.
    • Fix: Move the 9-line comment block for compute.requireOsLogin from data/org-policies/compute_policy.yaml into data/custom-org-policies/compute_policy.yaml directly above compute.requireOsLogin:, and add a trailing newline at the end of data/custom-org-policies/compute_policy.yaml.

@aghassemlouei
aghassemlouei force-pushed the feat/bootstrap-regime-conditional-oslogin branch 2 times, most recently from b4b9a27 to 414b717 Compare October 23, 2026 12:46
@aghassemlouei

aghassemlouei commented Oct 26, 2026 •

Copy link
Copy Markdown
Member Author

Addressed in 2722d43:

  1. (fast/stages-aw/0-bootstrap/organization.tf, @Calvin-Cheng1): Removed the try({ for k, v in ... : k => v }, {}) wrappers around yamldecode(file(...)) and yamldecode(templatefile(...)) so malformed YAML or template syntax errors fail fast instead of silently evaluating to {}.
  2. (fast/stages-aw/0-bootstrap/import.sh, @Calvin-Cheng1): Updated import.sh to query evaluated keys from echo 'keys(local.org_policies)' | terraform console rather than grepping unrendered YAML template files.
  3. (fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml, @Calvin-Cheng1): Simplified the template condition to %{ if !contains(["IL4", "IL5"], regime) ~}.
  4. (fast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yaml, fast/stages-aw/0-bootstrap/data/custom-org-policies/compute_policy.yaml, @Calvin-Cheng1): Moved the compute.requireOsLogin comment block from data/org-policies/compute_policy.yaml into data/custom-org-policies/compute_policy.yaml and ensured a trailing newline at EOF.

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
aghassemlouei enabled auto-merge (squash) October 26, 2026 20:06
@aghassemlouei aghassemlouei added Framework - FedRAMP Moderate FedRAMP Moderate compliance regime and controls Framework - FedRAMP High FedRAMP High compliance regime and controls Framework - IL4 DoD Impact Level 4 (IL4) compliance regime and controls Framework - IL5 DoD Impact Level 5 (IL5) compliance regime and controls Security Something is insecure or can be secured labels Oct 26, 2026
@Calvin-Cheng1
Calvin-Cheng1 force-pushed the feat/bootstrap-regime-conditional-oslogin branch from 973460d to 2abd717 Compare October 27, 2026 05:13
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
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
aghassemlouei force-pushed the feat/bootstrap-regime-conditional-oslogin branch from 2abd717 to a558d48 Compare October 28, 2026 04:09
#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
aghassemlouei merged commit 936a692 into main Oct 28, 2026
22 checks passed
@aghassemlouei
aghassemlouei deleted the feat/bootstrap-regime-conditional-oslogin branch October 28, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request Framework - FedRAMP High FedRAMP High compliance regime and controls Framework - FedRAMP Moderate FedRAMP Moderate compliance regime and controls Framework - IL4 DoD Impact Level 4 (IL4) compliance regime and controls Framework - IL5 DoD Impact Level 5 (IL5) compliance regime and controls Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Scope - Fast Related to Fabric FAST deployment stages in the fast directory Security Something is insecure or can be secured

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]Customize Org Policy Enforcement Based on Regime Setting

2 participants