diff --git a/configs/module_call.go b/configs/module_call.go index 25f048136..eefb3f2cb 100644 --- a/configs/module_call.go +++ b/configs/module_call.go @@ -31,6 +31,13 @@ type ModuleCall struct { } func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagnostics) { + var diags hcl.Diagnostics + + // Produce deprecation messages for any pre-0.12-style + // single-interpolation-only expressions. + moreDiags := warnForDeprecatedInterpolationsInBody(block.Body) + diags = append(diags, moreDiags...) + mc := &ModuleCall{ Name: block.Labels[0], DeclRange: block.DefRange, @@ -41,7 +48,8 @@ func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagno schema = schemaForOverrides(schema) } - content, remain, diags := block.Body.PartialContent(schema) + content, remain, moreDiags := block.Body.PartialContent(schema) + diags = append(diags, moreDiags...) mc.Config = remain if !hclsyntax.ValidIdentifier(mc.Name) { diff --git a/configs/named_values.go b/configs/named_values.go index e0b708a1e..196104178 100644 --- a/configs/named_values.go +++ b/configs/named_values.go @@ -433,6 +433,8 @@ type Output struct { } func decodeOutputBlock(block *hcl.Block, override bool) (*Output, hcl.Diagnostics) { + var diags hcl.Diagnostics + o := &Output{ Name: block.Labels[0], DeclRange: block.DefRange, @@ -443,7 +445,13 @@ func decodeOutputBlock(block *hcl.Block, override bool) (*Output, hcl.Diagnostic schema = schemaForOverrides(schema) } - content, diags := block.Body.Content(schema) + // Produce deprecation messages for any pre-0.12-style + // single-interpolation-only expressions. + moreDiags := warnForDeprecatedInterpolationsInBody(block.Body) + diags = append(diags, moreDiags...) + + content, moreDiags := block.Body.Content(schema) + diags = append(diags, moreDiags...) if !hclsyntax.ValidIdentifier(o.Name) { diags = append(diags, &hcl.Diagnostic{ @@ -506,6 +514,11 @@ func decodeLocalsBlock(block *hcl.Block) ([]*Local, hcl.Diagnostics) { }) } + // Produce deprecation messages for any pre-0.12-style + // single-interpolation-only expressions. + moreDiags := warnForDeprecatedInterpolationsInExpr(attr.Expr) + diags = append(diags, moreDiags...) + locals = append(locals, &Local{ Name: name, Expr: attr.Expr, diff --git a/configs/resource.go b/configs/resource.go index 9b0e4ef1e..e5cc8c606 100644 --- a/configs/resource.go +++ b/configs/resource.go @@ -290,6 +290,7 @@ func decodeResourceBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) { } func decodeDataBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) { + var diags hcl.Diagnostics r := &Resource{ Mode: addrs.DataResourceMode, Type: block.Labels[0], @@ -298,7 +299,13 @@ func decodeDataBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) { TypeRange: block.LabelRanges[0], } - content, remain, diags := block.Body.PartialContent(dataBlockSchema) + // Produce deprecation messages for any pre-0.12-style + // single-interpolation-only expressions. + moreDiags := warnForDeprecatedInterpolationsInBody(block.Body) + diags = append(diags, moreDiags...) + + content, remain, moreDiags := block.Body.PartialContent(dataBlockSchema) + diags = append(diags, moreDiags...) r.Config = remain if !hclsyntax.ValidIdentifier(r.Type) { diff --git a/configs/testdata/warning-files/redundant_interp.tf b/configs/testdata/warning-files/redundant_interp.tf index 07db23b8c..a64d9940a 100644 --- a/configs/testdata/warning-files/redundant_interp.tf +++ b/configs/testdata/warning-files/redundant_interp.tf @@ -34,3 +34,20 @@ resource "null_resource" "a" { wrapped = ["${var.triggers["greeting"]}"] } } + +module "foo" { + source = "./foo" + foo = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated +} + +data "null_data_source" "b" { + has_computed_default = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated +} + +output "output" { + value = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated +} + +locals { + foo = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated +}