feat(multi-env): Phase D2 — Vault policies for erp-sandbox #3
Reference in New Issue
Block a user
Delete Branch "claude/phaseD-erp-sandbox-vault"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Phase D2 of ADR-0002 — the Vault layer for the ERP sandbox.
erpgainsenvs = ["prod", "sandbox"], which flows into theapp_policymodule (main.tf:81envs = each.value.envs). For erp the module now resolvesinstances = ["erp", "erp-sandbox"].Expected plan (~1 add, 1 change, 0 destroy)
vault_policy.app_non_prod["erp-sandbox"]erp-sandbox→ readskvv2/data/erp-sandbox/*+postgres/creds/erp-sandbox*(the sandbox pod's VSO uses it)vault_policy.ops["erp"]erp-opsCI policy gains the erp-sandboxkvv2/{data,delete,undelete,destroy,metadata}rules + erp-sandbox entries in the k8s-roleallowed_parameterlists, so CI can manage the sandboxerpruntime policy + all other apps render byte-identical (envsstill defaults to["prod"]); glob rules likepostgres/roles/erp*already covered sandboxNo destroy/replace. The merge gate is the CI
tofu applyshowing exactly this shape.Note: pre-existing latent bug spotted (NOT fixed here)
The
cmsentry uses the object keyops_policies, but the root schema field ispolicies(the module input isops_policies, wired atmain.tf:82asops_policies = each.value.policies). Terraform silently drops the unknownops_policiesattribute on thecmsobject, so cms'sfactory__cf_r2_arcodange_tfpolicy is not actually attached togitea_cicd_cms. Out of scope for this PR — flagging for a separate fix.Phase D sequence
iac/main.tffor_each → Vault k8s auth role +postgres/creds/erp-sandbox+kvv2/erp-sandbox/configerp-sandboxApplication🤖 Generated with Claude Code
ADR-0002 Phase D, Vault layer. `erp` gains `envs = ["prod", "sandbox"]`, which flows into the app_policy module (main.tf:81 `envs = each.value.envs`). For erp the module now resolves instances = ["erp", "erp-sandbox"], so the apply: - ADDS vault_policy.app_non_prod["erp-sandbox"] — the runtime policy named `erp-sandbox` (read kvv2/data/erp-sandbox/* + postgres/creds/erp-sandbox*), consumed by the sandbox pod's VSO. - UPDATES vault_policy.ops["erp"] in place — the `erp-ops` CI policy gains the erp-sandbox kvv2 data/delete/undelete/destroy/metadata rules + the erp-sandbox values in the k8s-role allowed_parameter lists, so CI can manage the sandbox instance. The glob rules (postgres/roles/erp*, kvv1/cloudflare/erp*, auth/kubernetes/role/erp*) already covered erp-sandbox, so they don't change. No destroy/replace. prod `erp` runtime policy + every other app render byte-identical (their envs still default to ["prod"]). Diff kept to the single erp line — the pre-existing cms/crowdsec/plausible alignment is left as-is on main (not reformatting unrelated entries). D2 of Phase D. D1 (postgres DB+role) = factory#17 (merged). D3 (erp iac creds + KV) and D4 (ArgoCD) follow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>