Skip to content

Commit 4660530

Browse files
authored
tfsdk: Clarify Attribute type DeprecationMessage documentation for Terraform 1.2.7 and later (#443)
Reference: hashicorp/terraform#31576
1 parent 9e664c7 commit 4660530

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

tfsdk/attribute.go

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,35 +79,39 @@ type Attribute struct {
7979
// file is sensitive.
8080
Sensitive bool
8181

82-
// DeprecationMessage defines warning diagnostic details to display to
83-
// practitioners configuring this Attribute. The warning diagnostic summary
84-
// is automatically set to "Attribute Deprecated" along with configuration
85-
// source file and line information.
82+
// DeprecationMessage defines warning diagnostic details to display when
83+
// practitioner configurations use this Attribute. The warning diagnostic
84+
// summary is automatically set to "Attribute Deprecated" along with
85+
// configuration source file and line information.
8686
//
87-
// This warning diagnostic is only displayed during Terraform's validation
88-
// phase when this field is a non-empty string, when the Attribute is
89-
// Required or Optional, and if the practitioner configuration attempts to
90-
// set the attribute value to a known or unknown value (which may
91-
// eventually be null). It cannot detect practitioner configuration values
92-
// set directly to null, as there is no way for the framework to
93-
// differentiate between an unset and null configuration due to how
94-
// Terraform sends configuration information across the protocol, however
95-
// this is unlikely in a real world configuration.
87+
// Set this field to a practitioner actionable message such as:
9688
//
97-
// This field has no effect when the Attribute is Computed-only (read-only;
98-
// not Required or Optional) and a practitioner attempts to reference
99-
// this Attribute value in their configuration. There is a Terraform
100-
// feature request to support this type of functionality:
89+
// - "Configure other_attribute instead. This attribute will be removed
90+
// in the next major version of the provider."
91+
// - "Remove this attribute's configuration as it no longer is used and
92+
// the attribute will be removed in the next major version of the
93+
// provider."
10194
//
102-
// https://github.com/hashicorp/terraform/issues/7569
95+
// In Terraform 1.2.7 and later, this warning diagnostic is displayed any
96+
// time a practitioner attempts to configure a value for this attribute and
97+
// certain scenarios where this attribute is referenced.
10398
//
104-
// Set this field to a practitioner actionable message such as:
99+
// In Terraform 1.2.6 and earlier, this warning diagnostic is only
100+
// displayed when the Attribute is Required or Optional, and if the
101+
// practitioner configuration sets the value to a known or unknown value
102+
// (which may eventually be null). It has no effect when the Attribute is
103+
// Computed-only (read-only; not Required or Optional).
104+
//
105+
// Across any Terraform version, there are no warnings raised for
106+
// practitioner configuration values set directly to null, as there is no
107+
// way for the framework to differentiate between an unset and null
108+
// configuration due to how Terraform sends configuration information
109+
// across the protocol.
110+
//
111+
// Additional information about deprecation enhancements for read-only
112+
// attributes can be found in:
105113
//
106-
// - "Configure other_attribute instead. This attribute will be removed
107-
// in the next major version of the provider."
108-
// - "Remove this attribute's configuration as it no longer is used and
109-
// the attribute will be removed in the next major version of the
110-
// provider."
114+
// - https://github.com/hashicorp/terraform/issues/7569
111115
//
112116
DeprecationMessage string
113117

website/docs/plugin/framework/schemas.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ description](#markdowndescription), so too can individual attributes.
252252

253253
### DeprecationMessage
254254

255-
Individual attributes can be deprecated similar to resources, data sources, and providers. When the `DeprecationMessage` value is a non-empty string, the framework will automatically raise a warning diagnostic to practitioners if a configuration value (known or unknown) is detected for the attribute during Terraform's validation phase:
255+
Individual attributes can be deprecated similar to resources, data sources, and providers. When the `DeprecationMessage` value is a non-empty string, the framework will automatically raise a warning diagnostic to practitioners if a configuration value (known or unknown) or reference is detected for the attribute during Terraform's validation phase:
256256

257257
```text
258258
Warning: Attribute Deprecated
@@ -264,7 +264,7 @@ Warning: Attribute Deprecated
264264

265265
Use a practitioner actionable recommendation in `DeprecationMessage`, such as `"Configure other_attribute instead. This attribute will be removed in the next major version of the provider."` or `"Remove this attribute's configuration as it no longer is used and the attribute will be removed in the next major version of the provider."`.
266266

267-
~> **NOTE**: This warning diagnostic is only raised for configurable (`Required` or `Optional`) attributes when a configuration value is detected. A warning diagnostic is not raised for read-only (`Computed` only) attributes when referenced.
267+
~> **NOTE**: In Terraform 1.2.6 and earlier, a deprecation warning diagnostic is only raised for configurable (`Required` or `Optional`) attributes when a configuration value is detected. A warning diagnostic is not raised for read-only (`Computed` only) attributes when referenced.
268268

269269
### Validators
270270

0 commit comments

Comments
 (0)