Skip to content

Commit 7b15bdc

Browse files
authored
Standardized required_with behavior for write-only fields (#14941)
1 parent c4a23a8 commit 7b15bdc

File tree

6 files changed

+46
-22
lines changed

6 files changed

+46
-22
lines changed

mmv1/products/bigquerydatatransfer/Config.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,30 +222,32 @@ properties:
222222
to a different credential configuration in the config will require an apply to update state.
223223
url_param_only: true
224224
properties:
225-
- name: 'secretAccessKeyWoVersion'
226-
type: Integer
227-
url_param_only: true
228-
required_with:
229-
- 'sensitive_params.0.secretAccessKeyWo'
230-
description: |
231-
The version of the sensitive params - used to trigger updates of the write-only params. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)
232225
- name: 'secretAccessKey'
233226
type: String
234227
description: |
235228
The Secret Access Key of the AWS account transferring data from.
236229
sensitive: true
237230
at_least_one_of:
238-
- 'sensitive_params.0.secretAccessKey'
239-
- 'sensitive_params.0.secretAccessKeyWo'
231+
- 'sensitive_params.0.secret_access_key'
232+
- 'sensitive_params.0.secret_access_key_wo'
240233
conflicts:
241-
- 'sensitive_params.0.secretAccessKeyWo'
234+
- 'sensitive_params.0.secret_access_key_wo'
242235
- name: 'secretAccessKeyWo' # Wo is convention for write-only properties
243236
type: String
244237
description: |
245238
The Secret Access Key of the AWS account transferring data from.
246239
write_only: true
247240
at_least_one_of:
248-
- 'sensitive_params.0.secretAccessKeyWo'
249-
- 'sensitive_params.0.secretAccessKey'
241+
- 'sensitive_params.0.secret_access_key_wo'
242+
- 'sensitive_params.0.secret_access_key'
250243
conflicts:
251-
- 'sensitive_params.0.secretAccessKey'
244+
- 'sensitive_params.0.secret_access_key'
245+
required_with:
246+
- 'sensitive_params.0.secret_access_key_wo_version'
247+
- name: 'secretAccessKeyWoVersion'
248+
type: Integer
249+
url_param_only: true
250+
required_with:
251+
- 'sensitive_params.0.secret_access_key_wo'
252+
description: |
253+
The version of the sensitive params - used to trigger updates of the write-only params. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)

mmv1/products/monitoring/UptimeCheckConfig.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,16 @@ properties:
247247
type: String
248248
description: The password to authenticate.
249249
exactly_one_of:
250-
- 'password'
251-
- 'password_wo'
250+
- 'http_check.0.auth_info.0.password_wo'
251+
- 'http_check.0.auth_info.0.password'
252252
sensitive: true
253253
custom_flatten: 'templates/terraform/custom_flatten/uptime_check_http_password.tmpl'
254254
- name: 'passwordWo'
255255
type: String
256256
description: The password to authenticate.
257257
exactly_one_of:
258-
- 'passwordWo'
259-
- 'password'
258+
- 'http_check.0.auth_info.0.password_wo'
259+
- 'http_check.0.auth_info.0.password'
260260
required_with:
261261
- 'http_check.0.auth_info.0.password_wo_version'
262262
write_only: true

mmv1/products/secretmanager/SecretVersion.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,23 @@ properties:
161161
description: The secret data. Must be no larger than 64KiB.
162162
api_name: data
163163
conflicts:
164-
- 'secretDataWo'
164+
- 'payload.0.secret_data_wo'
165165
immutable: true
166166
sensitive: true
167167
- name: 'secretDataWo'
168168
type: String
169169
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)
170170
api_name: data
171171
required_with:
172-
- 'SecretDataWoVersion'
172+
- 'payload.0.secret_data_wo_version'
173173
conflicts:
174-
- 'payload.0.secretData'
174+
- 'payload.0.secret_data'
175175
write_only: true
176-
- name: 'SecretDataWoVersion'
176+
- name: 'secretDataWoVersion'
177177
type: Integer
178178
default_value: 0
179179
url_param_only: true
180180
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)
181181
immutable: true
182+
required_with:
183+
- 'payload.0.secret_data_wo'

mmv1/third_party/terraform/services/sql/resource_sql_user.go

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

mmv1/third_party/terraform/services/sql/resource_sql_user_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ resource "google_sql_user" "user1" {
439439
instance = google_sql_database_instance.instance.name
440440
host = "gmail.com"
441441
password_wo = "%s"
442+
password_wo_version = 1
442443
}
443444
`, instance, password)
444445
}
@@ -460,7 +461,7 @@ resource "google_sql_user" "user1" {
460461
instance = google_sql_database_instance.instance.name
461462
host = "gmail.com"
462463
password_wo = "%s"
463-
password_wo_version = 1
464+
password_wo_version = 2
464465
}
465466
`, instance, password)
466467
}

mmv1/third_party/terraform/website/docs/guides/version_7_upgrade.html.markdown

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

218218
Remove `post_startup_script_config` from your configuration after upgrade.
219219

220+
## Resource: `google_monitoring_uptime_check_config`
221+
222+
### Exactly one of `http_check.auth_info.password` and `http_check.auth_info.password_wo` must be set
223+
224+
At least one must be set, and setting both would make it unclear which was being used.
225+
220226
## Resource: `google_network_services_lb_traffic_extension`
221227

222228
### `load_balancing_scheme` is now required
@@ -249,6 +255,18 @@ Remove `service_config.service` from your configuration after upgrade.
249255

250256
Remove `template.containers.depends_on` from your configuration after upgrade.
251257

258+
## Resource: `google_secret_manager_secret_version`
259+
260+
### `secret_data_wo` and `secret_data_wo_version` must be set together
261+
262+
This standardizes the behavior of write-only fields across the provider and makes it easier to remember to update the fields together.
263+
264+
## Resource: `google_sql_user`
265+
266+
### `password_wo_version` is now required when `password_wo` is set
267+
268+
This standardizes the behavior of write-only fields across the provider and makes it easier to remember to update the fields together.
269+
252270
## Resource: `google_vertex_ai_endpoint`
253271

254272
### `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)