Skip to content

Commit 6f0b90f

Browse files
BBBmauramonvermeulenmelinath
authored
mmv1/docs: move write-only arguments into arguments section (#15385)
Co-authored-by: Ramon Vermeulen <[email protected]> Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
1 parent 94f663d commit 6f0b90f

File tree

10 files changed

+32
-43
lines changed

10 files changed

+32
-43
lines changed

mmv1/api/resource.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,6 @@ func (r *Resource) attachConstraintGroup(groupType string, source []string) *[]s
850850
}
851851

852852
func buildWriteOnlyField(name string, versionFieldName string, originalField *Type) *Type {
853-
description := fmt.Sprintf("%s Note: This property is write-only and will not be read from the API. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)", originalField.Description)
854853
originalFieldLineage := originalField.TerraformLineage()
855854
newFieldLineage := strings.ReplaceAll(originalFieldLineage, google.Underscore(originalField.Name), google.Underscore(name))
856855
requiredWith := strings.ReplaceAll(originalFieldLineage, google.Underscore(originalField.Name), google.Underscore(versionFieldName))
@@ -863,7 +862,7 @@ func buildWriteOnlyField(name string, versionFieldName string, originalField *Ty
863862
options := []func(*Type){
864863
propertyWithType("String"),
865864
propertyWithRequired(false),
866-
propertyWithDescription(description),
865+
propertyWithDescription(originalField.Description),
867866
propertyWithWriteOnly(true),
868867
propertyWithApiName(apiName),
869868
propertyWithIgnoreRead(true),
@@ -898,7 +897,7 @@ func buildWriteOnlyField(name string, versionFieldName string, originalField *Ty
898897
}
899898

900899
func buildWriteOnlyVersionField(name string, originalField *Type, writeOnlyField *Type) *Type {
901-
description := fmt.Sprintf("Triggers update of %s write-only. For more info see [updating write-only attributes](/docs/providers/google/guides/using_write_only_attributes.html#updating-write-only-attributes)", google.Underscore(writeOnlyField.Name))
900+
description := fmt.Sprintf("Triggers update of `%s` write-only. Increment this value when an update to `%s` is needed. For more info see [updating write-only arguments](/docs/providers/google/guides/using_write_only_arguments.html#updating-write-only-arguments)", google.Underscore(writeOnlyField.Name), google.Underscore(writeOnlyField.Name))
902901
requiredWith := strings.ReplaceAll(originalField.TerraformLineage(), google.Underscore(originalField.Name), google.Underscore(writeOnlyField.Name))
903902

904903
options := []func(*Type){

mmv1/products/bigquerydatatransfer/Config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ properties:
228228
required_with:
229229
- 'sensitive_params.0.secretAccessKeyWo'
230230
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)
231+
The version of the sensitive params - used to trigger updates of the write-only params. For more info see [updating write-only arguments](/docs/providers/google/guides/using_write_only_arguments.html#updating-write-only-arguments)
232232
- name: 'secretAccessKey'
233233
type: String
234234
description: |

mmv1/products/secretmanager/SecretVersion.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ properties:
189189
is_missing_in_cai: true
190190
- name: 'secretDataWo'
191191
type: String
192-
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)
192+
description: The secret data. Must be no larger than 64KiB. For more info see [updating write-only arguments](/docs/providers/google/guides/using_write_only_arguments.html#updating-write-only-arguments)
193193
api_name: data
194194
required_with:
195195
- 'SecretDataWoVersion'
@@ -200,5 +200,5 @@ properties:
200200
type: Integer
201201
default_value: 0
202202
url_param_only: true
203-
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)
203+
description: Triggers update of secret data write-only. For more info see [updating write-only arguments](/docs/providers/google/guides/using_write_only_arguments.html#updating-write-only-arguments)
204204
immutable: true

mmv1/templates/terraform/property_documentation.html.markdown.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020
{{- end }}
2121
{{- if or $.WriteOnlyLegacy $.WriteOnly }}
2222
**Note**: This property is write-only and will not be read from the API.
23+
24+
~> **Note:** One of `{{ slice (underscore $.Name) 0 (sub (len (underscore $.Name)) 3) }}` or `{{ underscore $.Name }}` can only be set.
2325
{{- end }}
2426
{{- if and (not $.FlattenObject) $.NestedProperties }}
2527
Structure is [documented below](#nested_{{ $.LineageAsSnakeCase}}).
2628
{{- end }}
29+
2730
{{- if $.DeprecationMessage }}
2831

2932
~> **Warning:** {{ $.DeprecationMessage }}

mmv1/templates/terraform/resource.html.markdown.tmpl

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ values will be stored in the raw state as plain text: {{ $.SensitivePropsToStrin
6060
{{ end }}
6161
{{- if $.WriteOnlyProps }}
6262
~> **Note:** All arguments marked as write-only values will not be stored in the state: {{ $.WriteOnlyPropsToString }}.
63-
[Read more about Write-only Attributes](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/write-only-arguments).
63+
[Read more about Write-only Arguments](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/write-only-arguments).
6464
{{ end }}
6565
{{- if $.Examples }}
6666
{{- range $e := $.Examples }}
@@ -110,13 +110,13 @@ The following arguments are supported:
110110
{{ "" }}
111111
{{ "" }}
112112
{{- range $p := $.RootProperties }}
113-
{{- if and $p.Required (not $p.WriteOnlyLegacy) (not $p.WriteOnly) }}
113+
{{- if $p.Required }}
114114
{{- trimTemplate "property_documentation.html.markdown.tmpl" $p -}}
115115
{{- end }}
116116
{{- end }}
117117
{{ "" }}
118118
{{- range $p := $.RootProperties }}
119-
{{- if and (not $p.Required) (not $p.Output) (not $p.WriteOnlyLegacy) (not $p.WriteOnly) }}
119+
{{- if and (not $p.Required) (not $p.Output) }}
120120
{{- trimTemplate "property_documentation.html.markdown.tmpl" $p -}}
121121
{{- end }}
122122
{{- end }}
@@ -146,19 +146,6 @@ The following arguments are supported:
146146
{{- end}}
147147
{{- end }}
148148
{{- "" }}
149-
{{- if $.WriteOnlyProps }}
150-
## Ephemeral Attributes Reference
151-
152-
The following write-only attributes are supported:
153-
{{ range $p := $.RootProperties }}
154-
{{- if or $p.WriteOnlyLegacy $p.WriteOnly }}
155-
{{- trimTemplate "property_documentation.html.markdown.tmpl" $p }}
156-
{{- end}}
157-
{{- end }}
158-
{{ range $p := $.AllUserProperties }}
159-
{{- trimTemplate "nested_property_write_only_documentation.html.markdown.tmpl" $p }}
160-
{{- end }}
161-
{{- end }}
162149
## Attributes Reference
163150

164151
In addition to the arguments listed above, the following computed attributes are exported:

mmv1/third_party/terraform/website/docs/ephemeral-resources/service_account_id_token.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ For more information see
1313

1414
## Example Usage - ServiceAccount JSON credential file.
1515

16-
-> **Note:** If you run this example configuration you will be able to see ephemeral.google_service_account_id_token.oidc in terraform plan and apply terminal output but you will not see it in state, as ephemeral resources are excluded from state. In future, when write-only attributes are added to resources in the Google provider, ephemeral resources such as google_service_account_id_token could be used to set field values when creating managed resources.
16+
-> **Note:** If you run this example configuration you will be able to see ephemeral.google_service_account_id_token.oidc in terraform plan and apply terminal output but you will not see it in state, as ephemeral resources are excluded from state. In future, when write-only arguments are added to resources in the Google provider, ephemeral resources such as google_service_account_id_token could be used to set field values when creating managed resources.
1717

1818
`google_service_account_id_token` will use the configured [provider credentials](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#credentials-1)
1919

@@ -25,7 +25,7 @@ For more information see
2525

2626
## Example Usage - Service Account Impersonation.
2727

28-
-> **Note:** If you run this example configuration you will be able to see ephemeral.google_service_account_id_token.oidc in terraform plan and apply terminal output but you will not see it in state, as ephemeral resources are excluded from state. In future, when write-only attributes are added to resources in the Google provider, ephemeral resources such as google_service_account_id_token could be used to set field values when creating managed resources.
28+
-> **Note:** If you run this example configuration you will be able to see ephemeral.google_service_account_id_token.oidc in terraform plan and apply terminal output but you will not see it in state, as ephemeral resources are excluded from state. In future, when write-only arguments are added to resources in the Google provider, ephemeral resources such as google_service_account_id_token could be used to set field values when creating managed resources.
2929

3030
Ephemeral resource `google_service_account_id_token` will use background impersonated credentials provided by [google_service_account_access_token](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/service_account_access_token).
3131

mmv1/third_party/terraform/website/docs/ephemeral-resources/service_account_jwt.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This ephemeral resource provides a [self-signed JWT](https://cloud.google.com/ia
1010

1111
## Example Usage
1212

13-
-> **Note:** If you run this example configuration you will be able to see ephemeral.google_service_account_jwt.foo in terraform plan and apply terminal output but you will not see it in state, as ephemeral resources are excluded from state. In future, when write-only attributes are added to resources in the Google provider, ephemeral resources such as google_service_account_jwt could be used to set field values when creating managed resources.
13+
-> **Note:** If you run this example configuration you will be able to see ephemeral.google_service_account_jwt.foo in terraform plan and apply terminal output but you will not see it in state, as ephemeral resources are excluded from state. In future, when write-only arguments are added to resources in the Google provider, ephemeral resources such as google_service_account_jwt could be used to set field values when creating managed resources.
1414

1515
Note: in order to use the following, the caller must have _at least_ `roles/iam.serviceAccountTokenCreator` on the `target_service_account`.
1616

mmv1/third_party/terraform/website/docs/ephemeral-resources/service_account_key.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Get an ephemeral service account public key. For more information, see [the offi
1010

1111
## Example Usage
1212

13-
-> **Note:** If you run this example configuration you will be able to see ephemeral.google_service_account_key.mykey in terraform plan and apply terminal output but you will not see it in state, as ephemeral resources are excluded from state. In future, when write-only attributes are added to resources in the Google provider, ephemeral resources such as google_service_account_key could be used to set field values when creating managed resources.
13+
-> **Note:** If you run this example configuration you will be able to see ephemeral.google_service_account_key.mykey in terraform plan and apply terminal output but you will not see it in state, as ephemeral resources are excluded from state. In future, when write-only arguments are added to resources in the Google provider, ephemeral resources such as google_service_account_key could be used to set field values when creating managed resources.
1414

1515

1616
```hcl

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ These are based on existing data sources already in the provider. In future you
2222

2323
## Use the Google Cloud provider's new ephemeral resources
2424

25-
Ephemeral resources are a source of ephemeral data, and they can be referenced in your configuration just like the attributes of resources and data sources. However, a field that references an ephemeral resource must be capable of handling ephemeral data. Due to this, resources in the Google Cloud provider will need to be updated so they include write-only attributes that are capable of using ephemeral data while not storing those values in the resource's state.
25+
Ephemeral resources are a source of ephemeral data, and they can be referenced in your configuration just like the attributes of resources and data sources. However, a field that references an ephemeral resource must be capable of handling ephemeral data. Due to this, resources in the Google Cloud provider will need to be updated so they include write-only arguments that are capable of using ephemeral data while not storing those values in the resource's state.
2626

2727
Until then, ephemeral resources can only be used to pass values into the provider block, which is already capable of receiving ephemeral values.
2828

mmv1/third_party/terraform/website/docs/guides/using_write_only_attributes.html.markdown renamed to mmv1/third_party/terraform/website/docs/guides/using_write_only_arguments.html.markdown

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
---
2-
page_title: "Use write-only attributes in the Google Cloud provider"
2+
page_title: "Use write-only arguments in the Google Cloud provider"
33
description: |-
4-
How to use write-only attributes in the Google Cloud provider
4+
How to use write-only arguments in the Google Cloud provider
55
---
66

7-
# Write-only attributes in the Google Cloud provider
7+
# Write-only arguments in the Google Cloud provider
88

9-
The Google Cloud provider has introduced new write-only attributes for a more secure way to manage data. The new `WriteOnly` attribute accepts values from configuration and will not be stored in plan or state providing an additional layer of security and control over data access.
9+
The Google Cloud provider has introduced new write-only arguments for a more secure way to manage data. These arguments accept values from configuration and will not be stored in plan or state providing an additional layer of security and control over data access.
1010

11-
For more information, see the [official HashiCorp documentation for Write-only Attributes](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/write-only-arguments).
11+
For more information, see the [official HashiCorp documentation for Write-only Arguments](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/write-only-arguments).
1212

13-
The Google Cloud provider has added the following write-only attributes:
13+
The Google Cloud provider has added the following write-only arguments:
1414
- [`google_sql_user: password_wo`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_user#password-1)
1515
- [`google_secret_manager_secret_version: secret_data_wo`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/secret_manager_secret_version#secret_data_wo)
1616
- [`google_bigquery_data_transfer_config: sensitive_params.secret_access_key_wo`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_data_transfer_config#secret_access_key_wo)
1717

18-
These were chosen due to them being marked as sensitive already in the provider. Although sensitive attributes do not appear in `terraform plan`, they are still stored in the Terraform state. Write-only attributes allow users to access and use data in their configurations without that data being stored in Terraform state.
18+
These were chosen due to them being marked as sensitive already in the provider. Although sensitive arguments do not appear in `terraform plan`, they are still stored in the Terraform state. Write-only arguments allow users to access and use data in their configurations without that data being stored in Terraform state.
1919

20-
## Use the Google Cloud provider's new write-only attributes
20+
## Use the Google Cloud provider's new write-only arguments
2121

22-
The following sections show how to use the new write-only attributes in the Google Cloud provider.
22+
The following sections show how to use the new write-only argument in the Google Cloud provider.
2323

24-
### Applying a write-only attribute
24+
### Applying a write-only argument
2525

26-
The following example shows how to apply a write-only attribute. All write-only attributes are marked with the `wo` suffix and can not be used with the attribute that it's mirroring. For example, `secret_data_wo` can not be used with `secret_data`.
26+
The following example shows how to apply a write-only argument. All write-only arguments are marked with the `wo` suffix and can't be used with the argument that it's mirroring. For example, `secret_data_wo` can not be used with `secret_data`.
2727

2828
```hcl
2929
resource "google_sql_database_instance" "instance" {
@@ -44,7 +44,7 @@ resource "google_sql_user" "user1" {
4444
}
4545
```
4646

47-
During `terraform plan` you will see that the write-only attribute is marked appropriately:
47+
During `terraform plan` you will see that the write-only argument is marked appropriately:
4848

4949
```
5050
# google_sql_user.user1 will be created
@@ -88,11 +88,11 @@ Upon `terrform apply` you will see in `terraform.tfstate` that the write-only at
8888
},
8989
```
9090

91-
Any value that is set for a write-only attribute is nulled out before the RPC response is sent to Terraform.
91+
Any value that is set for a write-only argument is nulled out before the RPC response is sent to Terraform.
9292

93-
### Updating write-only attributes
93+
### Updating write-only arguments
9494

95-
Since write-only attributes are not stored in the Terraform state, they cannot be updated by just changing the value in the configuration due to the attribute being nulled out.
95+
Since write-only arguments are not stored in the Terraform state, they cannot be updated by just changing the value in the configuration due to the attribute being nulled out.
9696

9797
In order to update a write-only attribute we must change the write-only attribute's version.
9898

@@ -106,7 +106,7 @@ resource "google_sql_user" "user1" {
106106
}
107107
```
108108

109-
A `terraform apply` of this configuration will allow you to update the write-only attribute despite the new value not being shown in the plan.
109+
A `terraform apply` of this configuration will allow you to update the write-only argument despite the new value not being shown in the plan.
110110

111111
```hcl
112112
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

0 commit comments

Comments
 (0)