Repository navigation
feat(1-resman): support project organization policy overrides - #294
Conversation
ff1dcf6 to
d1119cd
Compare
7b33fca to
b70f24e
Compare
Calvin-Cheng1
left a comment
There was a problem hiding this comment.
Suggestions here:
I recommend simplifying the implementation so that organization policy exceptions are scoped strictly to the project level and loaded via var.factories_config.org_policies (matching 0-bootstrap).
Why This Change Is Needed
-
Security & Compliance:
In Assured Workloads landing zones (FedRAMP Moderate/High, DoD IL4/IL5), baseline organization policies are enforced at the Organization / Assured Workloads folder level in0-bootstrap. Any policy exception (POA&M / risk acceptance) should be scoped down to the specific project (tenant-self-iac-projectsortenant-self-main-projects) that requires it.- Applying exceptions at the environment folder (
module.branch-envs-folders) weakens the control for every tenant and project in that environment. - Applying exceptions at the tenant folder (
module.tenant-top-folders) weakens the control for both the privileged automation project (<env>-<tenant>-iac-core-0) and the workload project (<env>-<tenant>-main-0), as well as any future projects created under that folder.
- Applying exceptions at the environment folder (
-
optional(map(any), {})Breaks Terraform Type Unification:
Usingoptional(map(any), {})insidevar.envs_foldersandvar.tenants(map(object({...}))) causesterraform planto fail in common real-world scenarios:- Mixed policy types in a single map: Configuring both a boolean policy (
enforce = false) and a list policy (allow = { all = true }) in the same map fails with:Error: Invalid value for input variable ... attribute "iac_project_org_policies": all map elements must have the same type. - Different policies across environments/tenants: Configuring a boolean policy on one entry and a list policy (or a policy with a different rule structure) on another fails with:
Error: Invalid value for input variable ... cannot find a common base type for all elements. - Overriding one entry while leaving another at default
{}: Overriding even a single policy on one environment/tenant while leaving another at the default{}fails with:Error: Invalid value for input variable ... attribute types must all match for conversion to map.
- Mixed policy types in a single map: Configuring both a boolean policy (
-
Environment Scoping on Tenant Projects:
Inbranch-tenants.tf,local.tenant_envsis the Cartesian product ofvar.envs_folders×var.tenants("${e}-${t}"). Definingiac_project_org_policiesandmain_project_org_policiesdirectly onvar.tenants[tenant]applies the same project exception across all environments (dev,test,prod), making it impossible to grant adev-only project exception without also looseningprod.
Recommended Implementation
Instead of adding inline map(any) attributes to var.envs_folders and var.tenants:
- Remove folder-level overrides: Revert the changes in
fast/stages-aw/1-resman/branch-envs.tf,var.envs_folders, andmodule.tenant-top-foldersso organization policy exceptions cannot be applied broadly at the environment or tenant folder level. - Use
var.factories_config.org_policies: Addorg_policies = optional(string, "data/org-policies")tovar.factories_configinfast/stages-aw/1-resman/variables.tf(matching the pattern used in0-bootstrap), leavingvar.envs_foldersandvar.tenantsunchanged. - Wire project-scoped factory paths in
branch-tenants.tf: Passfactories_configtomodule.tenant-self-iac-projectsandmodule.tenant-self-main-projectsusing each project's environment-scoped name:tenant-self-iac-projects:factories_config = { org_policies = "${var.factories_config.org_policies}/${lower("${each.key}-iac-core-0")}" }tenant-self-main-projects:factories_config = { org_policies = "${var.factories_config.org_policies}/${lower("${each.key}-main-0")}" }
- Update documentation: Also fix the double-commented
# # tfdoc:file:descriptionheader on line 17 offast/stages-aw/1-resman/branch-tenants.tfand regeneratefast/stages-aw/1-resman/README.mdwithtools/tfdoc.py.
Because modules/project uses try(fileset(..., "*.yaml"), []), non-existent directories are safely ignored, boolean and list policies can be freely mixed in YAML files without Terraform type-unification errors, and exceptions are naturally scoped to an individual <env>-<tenant> project (e.g., data/org-policies/dev-team-a-main-0/policies.yaml).
b70f24e to
4689999
Compare
|
Updated the branch to remove the folder-level overrides, wire project-scoped |
Description
org_policies = optional(string, "data/org-policies")tovar.factories_configinfast/stages-aw/1-resman/variables.tfto support project-scoped organization policy YAML factories, fixing [Feature Request] Allow Organization policy exceptions at folder/project level #14.factories_config.org_policiespaths (${var.factories_config.org_policies}/${lower("${each.key}-iac-core-0")}and${var.factories_config.org_policies}/${lower("${each.key}-main-0")}) tomodule.tenant-self-iac-projectsandmodule.tenant-self-main-projectsinfast/stages-aw/1-resman/branch-tenants.tf.# tfdoc:file:descriptionannotation infast/stages-aw/1-resman/branch-tenants.tfand regeneratefast/stages-aw/1-resman/README.md.Fixes #14
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),terraform validate,python3 tools/check_boilerplate.py fast/stages-aw/1-resman, andpython3 tools/check_documentation.py fast/stages-aw/1-resman.