fix(database): make root password create-only for SecretBackendConnection (fixes #38)#136
Closed
clain23 wants to merge 1 commit into
Closed
fix(database): make root password create-only for SecretBackendConnection (fixes #38)#136clain23 wants to merge 1 commit into
clain23 wants to merge 1 commit into
Conversation
…tion Vault's database/config/<name> read API never returns the password, so Upjet's diff perpetually sees the passwordSecretRef-resolved password as a change and re-applies it on every reconcile/cold-start, clobbering a rotate-root'd root password (28P01). Add a TerraformCustomDiff that drops <engine>.0.password from the Update diff (non-empty TF state ID) while keeping it on Create. Crossplane-native equivalent of the TF lifecycle.ignore_changes=[<engine>[0].password] already used in maestra-io/vault. Lets the composition use full managementPolicies + passwordSecretRef without the deny-update workaround, eliminating the 403 path-exists collision. Fixes upbound#38 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
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.
Problem (fixes #38)
vault_database_secret_backend_connectionre-sends the rootpasswordon every reconcile, clobbering arotate-root'd password (28P01 / broken dynamic creds).Root cause: Vault's
database/config/<name>read API never returns the password, so the refreshed Terraform state has no password. Upjet then diffs the desired config (with the password resolved frompasswordSecretRef) against state (no password) → a perpetual non-empty diff on<engine>.0.password→databaseSecretBackendConnectionUpdate'sd.HasChange(passwordKey)is true every reconcile → the password is PUT back todatabase/config, overwriting whateverrotate-rootlast set.This makes the resource fundamentally incompatible with
rotate-root, which is the documented way to take ownership of the root credential after creation.Fix
A
TerraformCustomDiffthat drops every engine<engine>.0.passwordattribute from the Update diff (keyed on a non-empty Terraform state ID) while leaving the Create diff intact. The password is sent once at creation and never re-sent on reconcile, so a rotated password survives.This is the Crossplane-native equivalent of the well-known Terraform workaround
lifecycle.ignore_changes = [postgresql[0].password].config/database/config.go+ wiring inconfig/provider.go) — no schema/CRD change, nomake generatediff.GetConnectionDetailsMapping()(all 17 engines with a root password); a unit test guards against drift.Test
config/database/config_test.go: Create keeps the password; Update drops it for all engines; nil/Destroy diffs untouched; engine-list completeness.Validated in production (Crossplane v2) across two clusters: with this change the connections reconcile under full
managementPolicieswithout ever re-writingdatabase/config, and arotate-root'd password survives provider cold-starts.