-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue where removing optional fields in database secrets backend connection resource did not reset the fields to their default values #1737
Conversation
Config: testAccDatabaseSecretBackendConnectionConfig_postgresql_reset_optional_values(name, backend, parsedURL), | ||
PlanOnly: true, | ||
ExpectNonEmptyPlan: false, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if there's (or should there be?) a more built-in way to check this by default? My understanding is that for 99.9% of cases after a successful terraform apply
a subsequent plan should show no changes, otherwise it's an unintended drift bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just confirmed that the Terraform SDK by default will run a terraform plan
after each test step to ensure that the the updates take place with no drift. Adding a test step that causes the plan to be non-empty results in an error from the SDK after the test step, something like:
=== RUN TestAccDatabaseSecretBackendConnection_postgresql
resource_database_secret_backend_connection_test.go:771: Step 2/3 error: After applying this test step, the plan was not empty.
stdout:
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# vault_database_secret_backend_connection.test will be updated in-place
~ resource "vault_database_secret_backend_connection" "test" {
id = "tf-test-db-3935684109521394435/config/db-4017655576009088209"
name = "db-4017655576009088209"
# (6 unchanged attributes hidden)
~ postgresql {
- disable_escaping = true -> null
- username = "postgres" -> null
# (4 unchanged attributes hidden)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good after removing the extra test step, and thanks for adding a fix for this!
Community Note
Overview
The username & disable_escaping fields are not managed correctly causing unresolvable drift or bad updates if a previously defined value is removed from the stanza.
To reproduce:
terraform plan
will show unexpected drift:New behaviour:
terraform apply
, subsequentterraform plan
shows everything is up-to-date indicating that the statefile was updated correctly and the artificial drift is gone. The disable_escaping field also reverts back to its defaultfalse
value in Vault.This is backward compatible. Users currently experiencing this issue will have to execute a successful apply once after upgrading their provider to a version with the fix, then all subsequent plans will no longer show the unwanted drift.
Changelog:
Output from acceptance testing: