Repository navigation
Make just secrets-push the only writer of app secrets (ADR 0017) - #120
Merged
Merged
Conversation
Contributor
Author
|
Hm, check how this would look to be terraform only. Don't love the split between the two. Blocked for now |
Terraform's write_secrets now writes only the manifest's infra group (tailscale-auth-key, ghcr-pull-token) as azurerm_key_vault_secret.infra. moved blocks carry those keys over from .managed; a removed block with destroy = false drops the app secrets from state without deleting them from Key Vault. The app-secret Terraform inputs are gone from the module and both stacks. The Container App still references every enabled secret. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NinjaLikesCheez
force-pushed
the
claude/quirky-ardinghelli-d35e25
branch
from
October 19, 2026 08:38
60da00b to
dbb1075
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Two things wrote the manifest's
appsecrets into Key Vault:just secrets-push/just pushand Terraform'swrite_secrets. They collided: on 2026-10-15 a prod apply failed becausespacestate-user/spacestate-tokenwere in Key Vault (pushed by the tool) but not in Terraform inputs ("Resource precondition failed", or "already exists, needs import").What
infra/modules/pixel/secrets.tf:azurerm_key_vault_secret.managed→azurerm_key_vault_secret.infra, whosefor_eachiskv_infra_secret_names(derived from the manifest inlocals.tf,group == "infra"). Onlytailscale-auth-keyandghcr-pull-tokenare ever written by Terraform.movedblocks:managed["tailscale-auth-key"]/managed["ghcr-pull-token"]→infra[...].removed { from = azurerm_key_vault_secret.managed lifecycle { destroy = false } }drops everything left (the app secrets) from state and leaves them in Key Vault.removedcan't take instance keys, so the infra keys are moved out first. Verified in a scratch config (child module,terraform_data, TF 1.13): app keys plan as "will no longer be managed by Terraform, but will not be destroyed", infra keys as "has moved to".key_vault_secret_idsstill covers every enabled secret, app group included.depends_onnow points at.infra; the ADR 0014discord-tokenrole assignment no longer depends on a Terraform-written secret (pushdiscord-tokenfirst).discord_token,admins_yaml,admins_yaml_file,home_assistant_token,mastodon_access_token,spacestate_user,spacestate_token,sentry_dsn) from the module and both stacks. Safe: an oldsecrets.auto.tfvarsthat still sets them only gets Terraform's "undeclared variable" warning, andjust pushalready refuses a shared tfvars that sets them.scripts/secrets-manifest.ts:terraformWrittenSecrets()(infra group). Parity test now checks Terraform's write map against it, that no app secret is writable, thatfor_eachuseskv_infra_secret_names, and that theremovedblock exists.secrets-sync.ts: dropped the "update secrets.auto.tfvars too" hint after an app push.docs/infra.md, architecture, AGENTS.md, changelog.What a maintainer should expect
Nothing was applied. Run
just tf-plan devandjust tf-plan prod:admins-yaml,discord-token,home-assistant-token,sentry-dsn, possiblyspacestate-user/spacestate-token) → "will no longer be managed by Terraform, but will not be destroyed".tailscale-auth-key/ghcr-pull-tokenin state → "has moved toazurerm_key_vault_secret.infra[...]".destroyof anyazurerm_key_vault_secret. Caveat: withwrite_secrets = false, infra secrets Terraform had written are destroyed, exactly as before this change; keepwrite_secrets = true(withtailscale_auth_key/container_registry_passwordinsecrets.auto.tfvars) if Terraform wrote those.secrets.auto.tfvarsto silence the undeclared-variable warnings./spacestate:just secrets-push prodfirst, then setspacestate_api_urland apply.Checks
just checkpasses (1968 tests).just tf-validatepasses (bootstrap, dev, prod).core/access*etc.), but this is infra + secrets: please have a human review the plan output before applying.🤖 Generated with Claude Code