Skip to content

Commit a1a5c41

Browse files
Standardized required_with behavior for write-only fields (#14941) (#24083)
[upstream:7b15bdcb5ac006445419f2ec4a7fcd4b7291fdd6] Signed-off-by: Modular Magician <[email protected]>
1 parent 982cf1d commit a1a5c41

File tree

7 files changed

+45
-12
lines changed

7 files changed

+45
-12
lines changed

.changelog/14941.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```release-note:breaking-change
2+
sql: on `google_sql_user`, made `password_wo_version` required when `password_wo` is set
3+
```
4+
5+
```release-note:breaking-change
6+
secretmanager: on `google_secret_manager_secret_version`, made `secret_data_wo` and `secret_data_wo_version` both required when one is set
7+
```
8+
9+
```release-note:breaking-change
10+
monitoring: on `google_monitoring_uptime_check_config`, made it required to set exactly one of `http_check.auth_info.password` and `http_check.auth_info.password_wo`
11+
```

google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ to a different credential configuration in the config will require an apply to u
301301
WriteOnly: true,
302302
ConflictsWith: []string{"sensitive_params.0.secret_access_key"},
303303
AtLeastOneOf: []string{"sensitive_params.0.secret_access_key_wo", "sensitive_params.0.secret_access_key"},
304+
RequiredWith: []string{"sensitive_params.0.secret_access_key_wo_version"},
304305
},
305306
"secret_access_key_wo_version": {
306307
Type: schema.TypeInt,

google/services/monitoring/resource_monitoring_uptime_check_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,14 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource {
176176
Optional: true,
177177
Description: `The password to authenticate.`,
178178
Sensitive: true,
179-
ExactlyOneOf: []string{},
179+
ExactlyOneOf: []string{"http_check.0.auth_info.0.password_wo", "http_check.0.auth_info.0.password"},
180180
},
181181
"password_wo": {
182182
Type: schema.TypeString,
183183
Optional: true,
184184
Description: `The password to authenticate.`,
185185
WriteOnly: true,
186-
ExactlyOneOf: []string{},
186+
ExactlyOneOf: []string{"http_check.0.auth_info.0.password_wo", "http_check.0.auth_info.0.password"},
187187
RequiredWith: []string{"http_check.0.auth_info.0.password_wo_version"},
188188
},
189189
"password_wo_version": {

google/services/secretmanager/resource_secret_manager_secret_version.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,29 @@ func ResourceSecretManagerSecretVersion() *schema.Resource {
9090
},
9191

9292
Schema: map[string]*schema.Schema{
93-
"secret_data_wo_version": {
94-
Type: schema.TypeInt,
95-
Optional: true,
96-
ForceNew: true,
97-
Description: `Triggers update of secret data write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
98-
Default: 0,
99-
},
10093
"secret_data": {
10194
Type: schema.TypeString,
10295
Optional: true,
10396
ForceNew: true,
10497
Description: `The secret data. Must be no larger than 64KiB.`,
10598
Sensitive: true,
106-
ConflictsWith: []string{},
99+
ConflictsWith: []string{"secret_data_wo"},
107100
},
108101
"secret_data_wo": {
109102
Type: schema.TypeString,
110103
Optional: true,
111104
Description: `The secret data. Must be no larger than 64KiB. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
112105
WriteOnly: true,
113106
ConflictsWith: []string{"secret_data"},
114-
RequiredWith: []string{},
107+
RequiredWith: []string{"secret_data_wo_version"},
108+
},
109+
"secret_data_wo_version": {
110+
Type: schema.TypeInt,
111+
Optional: true,
112+
ForceNew: true,
113+
Description: `Triggers update of secret data write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)`,
114+
Default: 0,
115+
RequiredWith: []string{"secret_data_wo"},
115116
},
116117

117118
"secret": {

google/services/sql/resource_sql_user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func ResourceSqlUser() *schema.Resource {
119119
Optional: true,
120120
WriteOnly: true,
121121
ConflictsWith: []string{"password"},
122+
RequiredWith: []string{"password_wo_version"},
122123
Description: `The password for the user. Can be updated. For Postgres instances this is a Required field, unless type is set to
123124
either CLOUD_IAM_USER or CLOUD_IAM_SERVICE_ACCOUNT.`,
124125
},

google/services/sql/resource_sql_user_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ resource "google_sql_user" "user1" {
455455
instance = google_sql_database_instance.instance.name
456456
host = "gmail.com"
457457
password_wo = "%s"
458+
password_wo_version = 1
458459
}
459460
`, instance, password)
460461
}
@@ -476,7 +477,7 @@ resource "google_sql_user" "user1" {
476477
instance = google_sql_database_instance.instance.name
477478
host = "gmail.com"
478479
password_wo = "%s"
479-
password_wo_version = 1
480+
password_wo_version = 2
480481
}
481482
`, instance, password)
482483
}

website/docs/guides/version_7_upgrade.html.markdown

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ Remove `description` from your configuration after upgrade.
231231

232232
Remove `post_startup_script_config` from your configuration after upgrade.
233233

234+
## Resource: `google_monitoring_uptime_check_config`
235+
236+
### Exactly one of `http_check.auth_info.password` and `http_check.auth_info.password_wo` must be set
237+
238+
At least one must be set, and setting both would make it unclear which was being used.
239+
234240
## Resource: `google_network_services_lb_traffic_extension`
235241

236242
### `load_balancing_scheme` is now required
@@ -263,6 +269,18 @@ Remove `service_config.service` from your configuration after upgrade.
263269

264270
Remove `template.containers.depends_on` from your configuration after upgrade.
265271

272+
## Resource: `google_secret_manager_secret_version`
273+
274+
### `secret_data_wo` and `secret_data_wo_version` must be set together
275+
276+
This standardizes the behavior of write-only fields across the provider and makes it easier to remember to update the fields together.
277+
278+
## Resource: `google_sql_user`
279+
280+
### `password_wo_version` is now required when `password_wo` is set
281+
282+
This standardizes the behavior of write-only fields across the provider and makes it easier to remember to update the fields together.
283+
266284
## Resource: `google_vertex_ai_endpoint`
267285

268286
### `enable_secure_private_service_connect` is removed as it is not available in the GA version of the API, only in the beta version.

0 commit comments

Comments
 (0)