Skip to content

fix(stages-aw)!: fix firewall constraint, viewer role, bucket CMEK, tenant IAM, and CI/CD templates - #419

Merged
aghassemlouei merged 3 commits into
mainfrom
fix/issue-369-bootstrap-resman
Nov 16, 2026
Merged

aghassemlouei merged 3 commits into
mainfrom
fix/issue-369-bootstrap-resman

Conversation

@Calvin-Cheng1

@Calvin-Cheng1 Calvin-Cheng1 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Resolves five security and functional defects across fast/stages-aw/0-bootstrap and fast/stages-aw/1-resman:

  1. Ingress firewall custom org-policy constraint (0-bootstrap): Replaces .all(...) with resource.sourceRanges.exists(range, range == '0.0.0.0/0' || range == '::/0') in custom.restrictFirewallRanges (data/custom-constraint-policies/networking.yaml) so multi-CIDR rules containing 0.0.0.0/0 and IPv6 world-open ::/0 rules are denied.
  2. Read-only storage_viewer custom role (0-bootstrap): Removes storage.objects.create from data/custom-roles/storage_viewer.yaml.
  3. State and checklist bucket CMEK & force_destroy (0-bootstrap, 1-resman): Exports automation.kms_keys.gcs (module.gcs-kms.keys.gcs.id) from Stage 0, adds backwards-compatible kms_keys = optional(object({ gcs = optional(string) }), {}) on Stage 1 var.automation, configures encryption_key and force_destroy = var.force_destroy on automation-tf-checklist-gcs (with depends_on = [module.organization, module.gcs-kms]) and all Stage 1 branch state buckets (data-platform, gcve, gke, project-factory, sandbox, teams), and replaces hardcoded KMS key strings in kms.tf, branch-networking.tf, and branch-security.tf.
  4. Tenant folder IAM key indexing & authoritative binding consolidation (1-resman): Indexes local.tenant_iam[k] instead of local.tenant_iam[each.value.tenant.name] in branch-tenants.tf and consolidates module.tenant-core-folders-iam and module.tenant-self-folders-iam into module.tenant-top-folders-iam with deep-merged role bindings so authoritative google_folder_iam_binding resources no longer overwrite one another.
  5. CI/CD workflow templates & team CI/CD outputs (0-bootstrap, 1-resman, fast/assets): Replaces hardcoded 0-bootstrap-providers.tf / 0-bootstrap-r-providers.tf with ${tf_providers_files.apply} and ${tf_providers_files.plan} in workflow-gitlab.yaml, and updates local.team_cicd_workflows, local.team_cicd_workflow_attrs, and output "team_cicd_repositories" in 1-resman/outputs.tf to pass audiences, service_accounts = { apply, plan }, and tf_providers_files = { apply, plan }.

Fixes #369

Breaking Changes

In `fast/stages-aw/1-resman`, `module.tenant-core-folders-iam` and `module.tenant-self-folders-iam` have been consolidated into `module.tenant-top-folders-iam` to eliminate conflicting authoritative `google_folder_iam_binding` resources on the same tenant folder.

Declarative `removed` blocks (`destroy = false`) in `fast/stages-aw/1-resman/branch-tenants.tf` automatically detach `module.tenant-core-folders-iam` and `module.tenant-self-folders-iam` from state without destroying existing bindings, and `output "team_cicd_repositories"` now exposes `service_account` as an `{ apply, plan }` map matching `cicd_repositories`.

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: AC-6 (Least Privilege), SC-7 (Boundary Protection), SC-28 (Protection of Information at Rest)

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

  • Added tests/test_bootstrap_resman_fixes.py covering all 5 defects (pytest: 136 passed).
  • Ran cli test suite (test_terraform_accepts_variables across all 6 regime fixtures, test_repo.py, test_render_sync.py) after updating cli/tests/fixtures/stage-outputs/0-bootstrap.auto.tfvars.json.
  • Ran terraform validate and offline terraform plan -refresh=false on both 0-bootstrap and 1-resman across multi-env/multi-tenant configurations, pre-upgrade 0-bootstrap.auto.tfvars.json backwards-compatibility inputs, and gitlab/github/sourcerepo branch + team CI/CD workflows (validating all rendered workflow outputs with yaml.safe_load).
  • Verified repository linters (check_boilerplate.py, terraform fmt -recursive -check, check_documentation.py, check_links.py, check_names.py, validate_metadata.py, ruff, pyright, and shell test suites).

…enant IAM, and CI/CD templates

Fixes #369

BREAKING CHANGE: fast/stages-aw/1-resman consolidates module.tenant-core-folders-iam and module.tenant-self-folders-iam into module.tenant-top-folders-iam. Existing deployments with var.tenants populated should run:
  terraform state rm 'module.tenant-core-folders-iam' 'module.tenant-self-folders-iam'
before applying Stage 1, and re-apply Stage 0 (0-bootstrap) first so 0-bootstrap.auto.tfvars.json exports automation.kms_keys.gcs.
@github-actions github-actions Bot added Scope - Fast Related to Fabric FAST deployment stages in the fast directory Bug Something isn't working Documentation Improvements or additions to documentation 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 Level of Effort - High Complex task taking a week or more; consider breaking this down into smaller issues. Priority - High Critical issues blocking development or users; urgent bugs or core features for release Security Something is insecure or can be secured labels Nov 13, 2026
@Calvin-Cheng1
Calvin-Cheng1 marked this pull request as draft November 13, 2026 15:58

@aghassemlouei aghassemlouei left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall these fixes look solid, especially the .exists(...) firewall constraint update, removing storage.objects.create from storage_viewer, and keying tenant_iam by k alongside the deep-merged tenant-top-folders-iam policy map. A few items to look at before marking this ready for review:

  1. fast/assets/templates/workflow-sourcerepo.yaml mismatch: Since this PR updates fast/assets/templates/workflow-gitlab.yaml alongside the 0-bootstrap and 1-resman templates, line 96 of fast/assets/templates/workflow-sourcerepo.yaml still references ${tf_providers_file.apply} (singular) instead of ${tf_providers_files.apply}, which fails templatefile() when given tf_providers_files.
  2. Pre-upgrade CMEK behavior on var.automation.kms_keys.gcs: Because kms_keys defaults to {} (gcs = null), applying Stage 1 with a pre-upgrade 0-bootstrap.auto.tfvars.json strips encryption from branch-network-gcs and branch-security-gcs, leaves the newly wired branch buckets unencrypted, and destroys resman_bootstrap_kms bindings. Consider either falling back via coalesce(var.automation.kms_keys.gcs, "projects/${var.automation.project_id}/locations/${var.regions.primary}/keyRings/gcs/cryptoKeys/gcs") or enforcing var.automation.kms_keys.gcs != null in a validation block so Stage 1 fails fast instead of silently clearing CMEK.
  3. Minor cleanup in branch-networking.tf and branch-security.tf: Both buckets still retain depends_on = [google_kms_crypto_key_iam_member.resman_bootstrap_kms], whereas Stage 0 already grants the automation project GCS service agent access in 0-bootstrap/kms.tf and resman_bootstrap_kms is only populated for tenant projects.
  4. Test coverage in tests/test_bootstrap_resman_fixes.py: Most checks use substring matching on .tf/.yaml files. Adding a templatefile() render + yaml.safe_load() check across all workflow-*.yaml templates (matching tests/test_workflow_templates.py) would catch template variable drift automatically.

@aghassemlouei aghassemlouei mentioned this pull request Nov 16, 2026
12 of 19 tasks
@Calvin-Cheng1
Calvin-Cheng1 marked this pull request as ready for review November 16, 2026 21:01

@aghassemlouei aghassemlouei left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for addressing all the review items, including the workflow-sourcerepo.yaml fix, local.gcs_kms_key fallback, declarative removed blocks in branch-tenants.tf, and full workflow template rendering tests.

@aghassemlouei
aghassemlouei merged commit a81c277 into main Nov 16, 2026
23 checks passed
@aghassemlouei
aghassemlouei deleted the fix/issue-369-bootstrap-resman branch November 16, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Documentation Improvements or additions to documentation 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 - High Complex task taking a week or more; consider breaking this down into smaller issues. Priority - High Critical issues blocking development or users; urgent bugs or core features for release 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.

[Bug] fast/stages-aw/0-bootstrap, 1-resman: fix custom firewall constraint bypass, state bucket CMEK, and tenant folder IAM

2 participants