Omit empty tune block on JWT auth backends and import the orphaned mount
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

This commit is contained in:
2026-11-10 23:32:19 +11:00
parent b9ae4a6802
commit a7dc1e9d25
5 changed files with 42 additions and 6 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ repos:
always_run: true
- id: tofu-module-tests
name: tofu module tests pass
entry: sh -c 'cd modules/vault_cluster/modules/auth_jwt_role && tofu init -backend=false -input=false >/dev/null && tofu test'
entry: sh -c 'for m in auth_jwt_backend auth_jwt_role; do (cd modules/vault_cluster/modules/$m && tofu init -backend=false -input=false >/dev/null && tofu test) || exit 1; done'
language: system
pass_filenames: false
always_run: true
+1 -1
View File
@@ -30,7 +30,7 @@ apply: init
test:
@uv run --with pyyaml --with pydantic python -m unittest discover -s tests -t .
@cd modules/vault_cluster/modules/auth_jwt_role && tofu init -backend=false -input=false >/dev/null && tofu test
@for m in auth_jwt_backend auth_jwt_role; do (cd modules/vault_cluster/modules/$$m && tofu init -backend=false -input=false >/dev/null && tofu test) || exit 1; done
format:
@echo "Formatting OpenTofu files..."
@@ -6,9 +6,13 @@ resource "vault_jwt_auth_backend" "jwt" {
bound_issuer = var.bound_issuer
default_role = var.default_role
tune {
default_lease_ttl = var.default_lease_ttl
max_lease_ttl = var.max_lease_ttl
listing_visibility = var.listing_visibility
# provider 5.6.0 panics on an all-null tune block
dynamic "tune" {
for_each = anytrue([for v in [var.default_lease_ttl, var.max_lease_ttl, var.listing_visibility] : v != null]) ? [1] : []
content {
default_lease_ttl = var.default_lease_ttl
max_lease_ttl = var.max_lease_ttl
listing_visibility = var.listing_visibility
}
}
}
@@ -0,0 +1,26 @@
mock_provider "vault" {}
variables {
path = "jwt/github/iuclabs"
oidc_discovery_url = "https://token.actions.githubusercontent.com"
bound_issuer = "https://token.actions.githubusercontent.com"
}
run "omit_tune_when_unset" {
command = plan
assert {
condition = length(vault_jwt_auth_backend.jwt.tune) == 0
error_message = "no tune block may render when every tune value is null"
}
}
run "render_tune_when_set" {
command = plan
variables { max_lease_ttl = "1h" }
assert {
condition = length(vault_jwt_auth_backend.jwt.tune) == 1 && vault_jwt_auth_backend.jwt.tune[0].max_lease_ttl == "1h"
error_message = "tune block must render with the configured values"
}
}
@@ -425,3 +425,9 @@ moved {
from = vault_policy.policies["pki_root/pki_root_roles_admin"]
to = module.vault_policy["pki_root/roles/admin"].vault_policy.this
}
# Mount enabled by a create that crashed before state was written
import {
to = module.auth_jwt_backend["jwt/github/iuclabs"].vault_jwt_auth_backend.jwt
id = "jwt/github/iuclabs"
}