Some checks failed
Helm Charts / Library charts tool (push) Blocked by required conditions
Helm Charts / Application charts pgcat (push) Blocked by required conditions
Helm Charts / Detect changed charts (pull_request) Successful in 19s
Helm Charts / Library charts tool (pull_request) Has been skipped
Helm Charts / Application charts pgcat (pull_request) Has been skipped
Helm Charts / Detect changed charts (push) Failing after 13m59s
The `applications` object field was declared `policies` in variables.tf, but the cms tfvars entry, the runbook (doc/runbooks/new-web-app/03-vault-platform.md), the guidebook (vibe/guidebooks/tools/secrets-and-vso.md) and the module input (modules/app_policy variable `ops_policies`) all use the name `ops_policies`. Because Terraform silently drops unknown attributes when converting a value to an object() type, cms's `ops_policies = ["factory__cf_r2_arcodange_tf"]` was discarded and `each.value.policies` fell back to [] — so gitea_cicd_cms never received the `factory__cf_r2_arcodange_tf` token policy (read on kvv1/cloudflare/r2/arcodange-tf + kvv1/zoho/self_client, defined in factory iac/cloudflare.tf). cms CI was missing its Cloudflare R2 Terraform-state permissions. Fix at the root: rename the schema field `policies` -> `ops_policies` (and its single reference main.tf:82 `each.value.policies` -> `each.value.ops_policies`), aligning the whole chain. This is lower-churn than renaming the tfvars key (the chosen alternative would also have required fixing the runbook + guidebook, which both already document `ops_policies`) and prevents the next app created from the runbook from re-introducing the same silently-dropped key. Behavioural change: gitea_cicd_cms gains `factory__cf_r2_arcodange_tf` in its token_policies. No other app sets this field (all default []), so no other role changes. Reviewer: confirm the R2 policy is the intended grant for cms CI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
87 lines
3.0 KiB
HCL
87 lines
3.0 KiB
HCL
resource "vault_auth_backend" "kubernetes" {
|
|
type = "kubernetes"
|
|
}
|
|
resource "vault_kubernetes_auth_backend_config" "config" {
|
|
backend = vault_auth_backend.kubernetes.path
|
|
kubernetes_host = "https://kubernetes.default.svc:443"
|
|
}
|
|
|
|
resource "vault_mount" "kvv2" {
|
|
path = "kvv2"
|
|
type = "kv"
|
|
options = { version = "2" }
|
|
description = "KV Version 2 secret engine mount"
|
|
}
|
|
|
|
|
|
resource "vault_mount" "postgres" {
|
|
path = "postgres"
|
|
type = "database"
|
|
}
|
|
|
|
resource "vault_database_secret_backend_connection" "postgres" {
|
|
backend = vault_mount.postgres.path
|
|
name = "postgres"
|
|
allowed_roles = ["*"]
|
|
root_rotation_statements = [
|
|
"ALTER USER \"{{name}}\" WITH PASSWORD '{{password}}';",
|
|
]
|
|
|
|
postgresql {
|
|
connection_url = "postgresql://{{username}}:{{password}}@pgbouncer.tools:5432/postgres?sslmode=disable"
|
|
username = var.POSTGRES_CREDENTIALS_EDITOR_USERNAME
|
|
password = var.POSTGRES_CREDENTIALS_EDITOR_PASSWORD
|
|
}
|
|
}
|
|
|
|
|
|
resource "vault_mount" "transit" {
|
|
path = "transit"
|
|
type = "transit"
|
|
description = "Pour le vault secret operator (vso) dans k3s en cas de redemarrage par exemple"
|
|
# default_lease_ttl_seconds = 3600
|
|
# max_lease_ttl_seconds = 86400
|
|
}
|
|
resource "vault_transit_secret_backend_key" "vso_client_cache" {
|
|
backend = vault_mount.transit.path
|
|
name = "vso-client-cache"
|
|
}
|
|
|
|
data "vault_policy_document" "vso_client_cache" {
|
|
rule {
|
|
path = "${vault_mount.transit.path}/encrypt/${vault_transit_secret_backend_key.vso_client_cache.name}"
|
|
capabilities = ["create", "update"]
|
|
}
|
|
rule {
|
|
path = "${vault_mount.transit.path}/decrypt/${vault_transit_secret_backend_key.vso_client_cache.name}"
|
|
capabilities = ["create", "update"]
|
|
}
|
|
}
|
|
resource "vault_policy" "vso_client_cache" {
|
|
name = "edit-vso-client-cache"
|
|
policy = data.vault_policy_document.vso_client_cache.hcl
|
|
}
|
|
|
|
resource "vault_kubernetes_auth_backend_role" "vso" {
|
|
backend = vault_auth_backend.kubernetes.path
|
|
role_name = "vault-secret-operator"
|
|
bound_service_account_names = ["hashicorp-vault-vault-secrets-operator-controller-manager"]
|
|
bound_service_account_namespaces = ["tools"]
|
|
token_ttl = 0
|
|
token_period = 120
|
|
token_policies = ["default", vault_policy.vso_client_cache.name]
|
|
audience = "vault"
|
|
alias_name_source = "serviceaccount_name"
|
|
}
|
|
|
|
module "app_policies" {
|
|
source = "./modules/app_policy"
|
|
for_each = { for app in var.applications : app.name => app }
|
|
name = each.value.name
|
|
envs = each.value.envs
|
|
ops_policies = each.value.ops_policies
|
|
service_account_names = each.value.service_account_names
|
|
service_account_namespaces = each.value.service_account_namespaces
|
|
gitea_app_id = var.gitea_app_id
|
|
}
|