fix(bigqueryconnection): flatten authentication fields from API response#17341
Conversation
The custom flatten function for `username_password` was returning values from state (`d.Get`) instead of the API response. As a result: 1. After importing a connection, `terraform plan` always showed `+ username = "..."` because the imported state was empty. 2. `secret_type` (output-only) was never populated and remained `null` in state. Read `username` and `password.secret_type` from the API response (`v`). Keep `password.plaintext` from state because the API redacts it on read. Also drop `username` from the example's `ignore_read_extra` since the field now round-trips through state correctly. Behavior change is limited to drift detection: external changes to `username` on the API side are now reflected on the next plan, which matches Terraform's expected semantics.
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @shuyama1, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
|
@shuyama1 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
|
Hi there, I'm the Modular magician. I've detected the following information about your changes for commit af125d1: Diff reportYour PR generated the following diffs in downstream repositories:
Test reportAnalytics
Affected Service Packages
Step 1: Replaying Mode 🟢 All tests passed in Replaying mode! No Recording was needed. View the build log @ota2000, @sachinpro, @shuyama1 VCR tests complete for af125d1! |
|
@GoogleCloudPlatform/terraform-team @shuyama1 This PR has been waiting for review for 1 week. Please take a look! Use the label |
|
Running some tests on TC |
ac45a1e
Description
The custom flatten function for the
username_passwordblock ingoogle_bigquery_connection.configuration.authentication, introduced in #17083, was returning values from state viad.Get(...)instead of the API response. This caused two visible bugs:terraform planalways reported+ username = "..."because the imported state was empty (d.Getreturned"").secret_type(output-only) was never populated, leaving it permanentlynullin state.Fix
usernameandpassword.secret_typefrom the API response (v).password.plaintextfrom state because the API redacts it on read (avoids a permadiff).configuration.0.authentication.0.username_password.0.usernamefrom the example test'signore_read_extra. It is no longer needed now that the field round-trips through state correctly.Behavior change
Limited to drift detection: external changes to
usernameon the API side are now reflected on the nextterraform plan, which matches Terraform's expected drift-detection semantics. Newly-created or already-applied resources see no diff (state and API agree).Reproduction
Before the fix, with a connection created out-of-band and imported into state:
terraform planreports+ username = "dbuser"even though the API already has the correct value.Release Note