auth-db backups: cutover to workload identity #27

Merged
nelsong6 merged 1 commit from claude/auth-db-backup-wi-chart into main 2026-05-16 00:29:12 -07:00
nelsong6 commented 2026-05-16 00:27:48 -07:00 (Migrated from github.com)

Second half of the connection-string → workload-identity migration (PR #26 was the tofu side; this is the chart cutover).

Cluster spec changes

  • serviceAccountTemplate.metadata.annotations.azure.workload.identity/client-id = 4d3946f7-3845-4cb4-84f7-f6210dda6f01 (UAMI client_id from #26)
  • inheritedMetadata.labels.azure.workload.identity/use: "true" so the azwi mutating webhook projects the SA token volume onto every pod the Cluster owns (primary + standby)
  • backup.barmanObjectStore.azureCredentials swapped from connectionString → inheritFromAzureAD: true
  • templates/externalsecret-cnpg-backups.yaml deleted (no longer consumed)

Tofu changes

  • Removed azurerm_key_vault_secret.auth_db_backup_connection_string. Tofu apply destroys the KV entry; Azure soft-delete retains it 30 days as a recovery floor.

Migration discipline

Per docs/migration-policy.md, no parallel auth paths. If WI fails after merge, fix forward — don't restore the connection-string flow. Soft-deleted KV entry is the worst-case fallback for the 30-day window.

Verification plan (post-merge)

  • kubectl exec auth-db-1 -- cat /var/run/secrets/azure/tokens/azure-identity-token | head -c 20 returns a JWT prefix (token volume projected)
  • kubectl apply -f a Backup CR; expect phase: completed within 60s
  • Blob lands in the auth-db container of authdbbackupspjbrsd

Also in this PR

.gitignore updated to add .claude/ so future commits in this repo don't accidentally embed the local Claude Code worktrees (the first amend on this branch cleaned up two accidental gitlink entries).

🤖 Generated with Claude Code

Second half of the connection-string → workload-identity migration (PR #26 was the tofu side; this is the chart cutover). ## Cluster spec changes - `serviceAccountTemplate.metadata.annotations.azure.workload.identity/client-id` = `4d3946f7-3845-4cb4-84f7-f6210dda6f01` (UAMI client_id from #26) - `inheritedMetadata.labels.azure.workload.identity/use: "true"` so the azwi mutating webhook projects the SA token volume onto every pod the Cluster owns (primary + standby) - `backup.barmanObjectStore.azureCredentials` swapped from `connectionString` → `inheritFromAzureAD: true` - `templates/externalsecret-cnpg-backups.yaml` deleted (no longer consumed) ## Tofu changes - Removed `azurerm_key_vault_secret.auth_db_backup_connection_string`. Tofu apply destroys the KV entry; Azure soft-delete retains it 30 days as a recovery floor. ## Migration discipline Per `docs/migration-policy.md`, no parallel auth paths. If WI fails after merge, fix forward — don't restore the connection-string flow. Soft-deleted KV entry is the worst-case fallback for the 30-day window. ## Verification plan (post-merge) - [ ] `kubectl exec auth-db-1 -- cat /var/run/secrets/azure/tokens/azure-identity-token | head -c 20` returns a JWT prefix (token volume projected) - [ ] `kubectl apply -f` a Backup CR; expect `phase: completed` within 60s - [ ] Blob lands in the `auth-db` container of `authdbbackupspjbrsd` ## Also in this PR `.gitignore` updated to add `.claude/` so future commits in this repo don't accidentally embed the local Claude Code worktrees (the first amend on this branch cleaned up two accidental gitlink entries). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-05-16 00:28:22 -07:00 (Migrated from github.com)

OpenTofu Plan

Click to expand plan output
random_password.better_auth_secret: Refreshing state... [id=none]
random_string.backups_suffix: Refreshing state... [id=pjbrsd]
data.azurerm_key_vault.main: Reading...
azurerm_resource_group.auth: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg]
azurerm_key_vault_secret.auth_db_backup_connection_string: Refreshing state... [id=https://romaine-kv.vault.azure.net/secrets/auth-db-backup-storage-connection/8514be902cc04157afdef5069ac48f9f]
data.azurerm_key_vault.main: Read complete after 0s [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/infra/providers/Microsoft.KeyVault/vaults/romaine-kv]
azurerm_key_vault_secret.better_auth_secret: Refreshing state... [id=https://romaine-kv.vault.azure.net/secrets/auth-better-auth-secret/c48ed1105b6e4428bda3f27c58f0a472]
azurerm_user_assigned_identity.auth_db_backup_writer: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/auth-db-backup-writer]
azurerm_storage_account.auth_db_backups: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.Storage/storageAccounts/authdbbackupspjbrsd]
azurerm_federated_identity_credential.auth_db_backup_writer: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/auth-db-backup-writer/federatedIdentityCredentials/auth-db]
azurerm_storage_container.auth_db_backups: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.Storage/storageAccounts/authdbbackupspjbrsd/blobServices/default/containers/auth-db]
azurerm_role_assignment.auth_db_backup_writer_blob_contributor: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.Storage/storageAccounts/authdbbackupspjbrsd/blobServices/default/containers/auth-db/providers/Microsoft.Authorization/roleAssignments/fa917197-6e52-c083-9cf1-4567db40084d]

OpenTofu used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  - destroy

OpenTofu will perform the following actions:

  # azurerm_key_vault_secret.auth_db_backup_connection_string will be destroyed
  # (because azurerm_key_vault_secret.auth_db_backup_connection_string is not in configuration)
  - resource "azurerm_key_vault_secret" "auth_db_backup_connection_string" {
      - id                      = "https://romaine-kv.vault.azure.net/secrets/auth-db-backup-storage-connection/8514be902cc04157afdef5069ac48f9f" -> null
      - key_vault_id            = "/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/infra/providers/Microsoft.KeyVault/vaults/romaine-kv" -> null
      - name                    = "auth-db-backup-storage-connection" -> null
      - resource_id             = "/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/infra/providers/Microsoft.KeyVault/vaults/romaine-kv/secrets/auth-db-backup-storage-connection/versions/8514be902cc04157afdef5069ac48f9f" -> null
      - resource_versionless_id = "/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/infra/providers/Microsoft.KeyVault/vaults/romaine-kv/secrets/auth-db-backup-storage-connection" -> null
      - tags                    = {} -> null
      - value                   = (sensitive value) -> null
      - value_wo_version        = 0 -> null
      - version                 = "8514be902cc04157afdef5069ac48f9f" -> null
      - versionless_id          = "https://romaine-kv.vault.azure.net/secrets/auth-db-backup-storage-connection" -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.
╷
│ Warning: Argument is deprecated
│ 
│   with azurerm_federated_identity_credential.auth_db_backup_writer,
│   on workload-identity.tf line 26, in resource "azurerm_federated_identity_credential" "auth_db_backup_writer":
│   26:   resource_group_name = azurerm_resource_group.auth.name
│ 
│ This field is no longer used and will be removed in the next major version
│ of the Azure Provider
│ 
│ (and one more similar warning elsewhere)
╵
╷
│ Warning: Deprecated attribute
│ 
│   on workload-identity.tf line 37, in resource "azurerm_role_assignment" "auth_db_backup_writer_blob_contributor":
│   37:   scope                = azurerm_storage_container.auth_db_backups.resource_manager_id
│ 
│ The attribute "resource_manager_id" is deprecated. Refer to the provider
│ documentation for details.
│ 
│ (and one more similar warning elsewhere)
╵

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan

To perform exactly these actions, run the following command to apply:
    tofu apply "tfplan"

### OpenTofu Plan <details> <summary>Click to expand plan output</summary> ``` random_password.better_auth_secret: Refreshing state... [id=none] random_string.backups_suffix: Refreshing state... [id=pjbrsd] data.azurerm_key_vault.main: Reading... azurerm_resource_group.auth: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg] azurerm_key_vault_secret.auth_db_backup_connection_string: Refreshing state... [id=https://romaine-kv.vault.azure.net/secrets/auth-db-backup-storage-connection/8514be902cc04157afdef5069ac48f9f] data.azurerm_key_vault.main: Read complete after 0s [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/infra/providers/Microsoft.KeyVault/vaults/romaine-kv] azurerm_key_vault_secret.better_auth_secret: Refreshing state... [id=https://romaine-kv.vault.azure.net/secrets/auth-better-auth-secret/c48ed1105b6e4428bda3f27c58f0a472] azurerm_user_assigned_identity.auth_db_backup_writer: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/auth-db-backup-writer] azurerm_storage_account.auth_db_backups: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.Storage/storageAccounts/authdbbackupspjbrsd] azurerm_federated_identity_credential.auth_db_backup_writer: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/auth-db-backup-writer/federatedIdentityCredentials/auth-db] azurerm_storage_container.auth_db_backups: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.Storage/storageAccounts/authdbbackupspjbrsd/blobServices/default/containers/auth-db] azurerm_role_assignment.auth_db_backup_writer_blob_contributor: Refreshing state... [id=/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/auth-rg/providers/Microsoft.Storage/storageAccounts/authdbbackupspjbrsd/blobServices/default/containers/auth-db/providers/Microsoft.Authorization/roleAssignments/fa917197-6e52-c083-9cf1-4567db40084d] OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: - destroy OpenTofu will perform the following actions:  # azurerm_key_vault_secret.auth_db_backup_connection_string will be destroyed # (because azurerm_key_vault_secret.auth_db_backup_connection_string is not in configuration)  - resource "azurerm_key_vault_secret" "auth_db_backup_connection_string" { - id = "https://romaine-kv.vault.azure.net/secrets/auth-db-backup-storage-connection/8514be902cc04157afdef5069ac48f9f" -> null - key_vault_id = "/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/infra/providers/Microsoft.KeyVault/vaults/romaine-kv" -> null - name = "auth-db-backup-storage-connection" -> null - resource_id = "/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/infra/providers/Microsoft.KeyVault/vaults/romaine-kv/secrets/auth-db-backup-storage-connection/versions/8514be902cc04157afdef5069ac48f9f" -> null - resource_versionless_id = "/subscriptions/aee0cbd2-8074-4001-b610-0f8edb4eaa3c/resourceGroups/infra/providers/Microsoft.KeyVault/vaults/romaine-kv/secrets/auth-db-backup-storage-connection" -> null - tags = {} -> null - value = (sensitive value) -> null - value_wo_version = 0 -> null - version = "8514be902cc04157afdef5069ac48f9f" -> null - versionless_id = "https://romaine-kv.vault.azure.net/secrets/auth-db-backup-storage-connection" -> null } Plan: 0 to add, 0 to change, 1 to destroy. ╷ │ Warning: Argument is deprecated │  │  with azurerm_federated_identity_credential.auth_db_backup_writer, │  on workload-identity.tf line 26, in resource "azurerm_federated_identity_credential" "auth_db_backup_writer": │  26: resource_group_name = azurerm_resource_group.auth.name │  │ This field is no longer used and will be removed in the next major version │ of the Azure Provider │  │ (and one more similar warning elsewhere) ╵ ╷ │ Warning: Deprecated attribute │  │  on workload-identity.tf line 37, in resource "azurerm_role_assignment" "auth_db_backup_writer_blob_contributor": │  37: scope = azurerm_storage_container.auth_db_backups.resource_manager_id │  │ The attribute "resource_manager_id" is deprecated. Refer to the provider │ documentation for details. │  │ (and one more similar warning elsewhere) ╵  ───────────────────────────────────────────────────────────────────────────── Saved the plan to: tfplan To perform exactly these actions, run the following command to apply: tofu apply "tfplan" ``` </details>
Sign in to join this conversation.
No description provided.