Namespace service account token map keys by account #31
Reference in New Issue
Block a user
Delete Branch "benvin/token-foreach-namespacing"
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?
Review finding carried over from #30:
local.service_account_tokenswas keyed by the bare token identifier, so if twoconfig/service_accounts/*.yamlever declared the same identifier,merge()would silently collapse them and one token would never be created. Its siblingservice_account_permissionsalready namespaces keys as"<account>/<permission>".Changes
service_account_tokensas"<service_account>/<identifier>", mirroring the permissions local.identifieras a field on the map value and use it forauthentik_token.identifier, so the Authentik-side identifier is unchanged.vault_kv_secret_v2.service_account_tokenkeeps indexing the token byeach.key; both maps re-key together.State impact
Re-keying a
for_eachre-addresses existing instances, which would otherwise destroy+recreate the livesa-agent-apitoken and rotate the key published to Vault. Twomoved {}blocks map the old addresses to the new ones, so the token is not recreated — the plan should show only the re-address, no changes:authentik_token.service_account["agent-api-token"]->["sa-agent-api/agent-api-token"]vault_kv_secret_v2.service_account_token["agent-api-token"]->["sa-agent-api/agent-api-token"]These are one-off migration blocks (the repo used none before) and can be deleted after this applies.
Verified with
pre-commit run(tofu fmt / validate / tflint all pass).