Skip to content

Commit 69b5079

Browse files
authored
helper/schema: Clarify Schema type Deprecated field usage (#1013)
Reference: #1012
1 parent 426ae64 commit 69b5079

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

Diff for: helper/schema/schema.go

+26-5
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,32 @@ type Schema struct {
311311
// "parent_block_name.0.child_attribute_name".
312312
RequiredWith []string
313313

314-
// Deprecated indicates the message to include in a warning diagnostic to
315-
// practitioners when this attribute is configured. Typically this is used
316-
// to signal that this attribute will be removed in the future and provide
317-
// next steps to the practitioner, such as using a different attribute,
318-
// different resource, or if it should just be removed.
314+
// Deprecated defines warning diagnostic details to display to
315+
// practitioners configuring this attribute or block. The warning
316+
// diagnostic summary is automatically set to "Argument is deprecated"
317+
// along with configuration source file and line information.
318+
//
319+
// This warning diagnostic is only displayed during Terraform's validation
320+
// phase when this field is a non-empty string, when the attribute is
321+
// Required or Optional, and if the practitioner configuration attempts to
322+
// set the attribute value to a known value. It cannot detect practitioner
323+
// configuration values that are unknown ("known after apply").
324+
//
325+
// This field has no effect when the attribute is Computed-only (read-only;
326+
// not Required or Optional) and a practitioner attempts to reference
327+
// this attribute value in their configuration. There is a Terraform
328+
// feature request to support this type of functionality:
329+
//
330+
// https://github.com/hashicorp/terraform/issues/7569
331+
//
332+
// Set this field to a practitioner actionable message such as:
333+
//
334+
// - "Configure other_attribute instead. This attribute will be removed
335+
// in the next major version of the provider."
336+
// - "Remove this attribute's configuration as it no longer is used and
337+
// the attribute will be removed in the next major version of the
338+
// provider."
339+
//
319340
Deprecated string
320341

321342
// ValidateFunc allows individual fields to define arbitrary validation

Diff for: website/docs/plugin/sdkv2/schemas/schema-methods.mdx

+12-1
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,22 @@ ComputedWhen []string
132132
// key.
133133
ConflictsWith []string
134134
135-
// When Deprecated is set, this attribute is deprecated.
135+
// When Deprecated is set, this attribute is deprecated and a warning
136+
// diagnostic will automatically be raised when it is configured.
136137
//
137138
// A deprecated field still works, but will probably stop working in near
138139
// future. This string is the message shown to the user with instructions on
139140
// how to address the deprecation.
141+
//
142+
// This warning diagnostic is only displayed during Terraform's validation
143+
// phase when the attribute is Required or Optional and if the practitioner
144+
// configuration attempts to set the attribute value to a known value. It
145+
// cannot detect practitioner configuration values that are unknown ("known
146+
// after apply").
147+
//
148+
// This field has no effect when the attribute is Computed-only (read-only;
149+
// not Required or Optional) and a practitioner attempts to reference
150+
// this attribute value in their configuration.
140151
Deprecated string
141152
142153
// When Removed is set, this attribute has been removed from the schema

0 commit comments

Comments
 (0)