@@ -74,14 +74,34 @@ func (b *Block) StaticValidateTraversal(traversal hcl.Traversal) tfdiags.Diagnos
7474 }
7575
7676 if attrS , exists := b .Attributes [name ]; exists {
77+ // Check for Deprecated status of this attribute.
78+ // We currently can't provide the user with any useful guidance because
79+ // the deprecation string is not part of the schema, but we can at
80+ // least warn them.
81+ //
82+ // This purposely does not attempt to recurse into nested attribute
83+ // types. Because nested attribute values are often not accessed via a
84+ // direct traversal to the leaf attributes, we cannot reliably detect
85+ // if a nested, deprecated attribute value is actually used from the
86+ // traversal alone. More precise detection of deprecated attributes
87+ // would require adding metadata like marks to the cty value itself, to
88+ // be caught during evaluation.
89+ if attrS .Deprecated {
90+ diags = diags .Append (& hcl.Diagnostic {
91+ Severity : hcl .DiagWarning ,
92+ Summary : `Deprecated attribute` ,
93+ Detail : fmt .Sprintf (`The attribute %q is deprecated. Refer to the provider documentation for details.` , name ),
94+ Subject : next .SourceRange ().Ptr (),
95+ })
96+ }
97+
7798 // For attribute validation we will just apply the rest of the
78- // traversal to an unknown value of the attribute type and pass through
79- // HCL's own errors, since we don't want to replicate all of HCL's type
80- // checking rules here.
99+ // traversal to an unknown value of the attribute type and pass
100+ // through HCL's own errors, since we don't want to replicate all
101+ // of HCL's type checking rules here.
81102 val := cty .UnknownVal (attrS .ImpliedType ())
82103 _ , hclDiags := after .TraverseRel (val )
83- diags = diags .Append (hclDiags )
84- return diags
104+ return diags .Append (hclDiags )
85105 }
86106
87107 if blockS , exists := b .BlockTypes [name ]; exists {
0 commit comments