Skip to content

Commit 3c4ee10

Browse files
authored
Add callout for PreferWriteOnlyAttribute validator (#1436)
1 parent 301ea9f commit 3c4ee10

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

helper/validation/write_only.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import (
2222
// For lists: cty.Index(cty.UnknownVal(cty.Number)),
2323
// For maps: cty.Index(cty.UnknownVal(cty.String)),
2424
// For sets: cty.Index(cty.UnknownVal(cty.Object(nil))),
25+
//
26+
// NOTE: This validator will produce persistent warnings for practitioners on every Terraform run as long as the specified non-write-only attribute
27+
// has a value in the configuration. The validator will also produce warnings for users of shared modules
28+
// who cannot immediately take action on the warning.
2529
func PreferWriteOnlyAttribute(oldAttribute cty.Path, writeOnlyAttribute cty.Path) schema.ValidateRawResourceConfigFunc {
2630
return func(ctx context.Context, req schema.ValidateResourceConfigFuncRequest, resp *schema.ValidateResourceConfigFuncResponse) {
2731
if !req.WriteOnlyAttributesAllowed {

website/docs/plugin/sdkv2/resources/write-only-arguments.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ if !woVal.IsNull() {
203203

204204
## PreferWriteOnlyAttribute Validator
205205

206+
<Note>
207+
208+
This validator will produce persistent warnings for practitioners on every Terraform run as long as the specified non-write-only attribute
209+
has a value in the configuration. The validator will also produce warnings for users of shared modules who cannot immediately take action on the warning.
210+
211+
</Note>
212+
206213
`PreferWriteOnlyAttribute()` is a validator that takes a `cty.Path` to an existing configuration attribute (required/optional) and a `cty.Path` to a write-only argument.
207214

208215
Use this validator when you have a write-only version of an existing attribute, and you want to encourage practitioners to use the write-only version whenever possible.

0 commit comments

Comments
 (0)