diff --git a/configs/configupgrade/test-fixtures/valid/noop/input/resources.tf b/configs/configupgrade/test-fixtures/valid/noop/input/resources.tf index 29ceef046..17f3f8c88 100644 --- a/configs/configupgrade/test-fixtures/valid/noop/input/resources.tf +++ b/configs/configupgrade/test-fixtures/valid/noop/input/resources.tf @@ -1,5 +1,10 @@ resource "test_instance" "example" { + tags = { + # Thingy thing + name = "foo bar baz" # this is a terrible name + } + connection { host = "127.0.0.1" } diff --git a/configs/configupgrade/test-fixtures/valid/noop/want/resources.tf b/configs/configupgrade/test-fixtures/valid/noop/want/resources.tf index 29ceef046..17f3f8c88 100644 --- a/configs/configupgrade/test-fixtures/valid/noop/want/resources.tf +++ b/configs/configupgrade/test-fixtures/valid/noop/want/resources.tf @@ -1,5 +1,10 @@ resource "test_instance" "example" { + tags = { + # Thingy thing + name = "foo bar baz" # this is a terrible name + } + connection { host = "127.0.0.1" } diff --git a/configs/configupgrade/upgrade_expr.go b/configs/configupgrade/upgrade_expr.go index 2f525a3b1..5d62643ba 100644 --- a/configs/configupgrade/upgrade_expr.go +++ b/configs/configupgrade/upgrade_expr.go @@ -192,9 +192,22 @@ Value: diags = diags.Append(moreDiags) valueSrc, moreDiags := upgradeExpr(item.Val, filename, interp, an) diags = diags.Append(moreDiags) + if item.LeadComment != nil { + for _, c := range item.LeadComment.List { + buf.WriteString(c.Text) + buf.WriteByte('\n') + } + } + buf.Write(keySrc) buf.WriteString(" = ") buf.Write(valueSrc) + if item.LineComment != nil { + for _, c := range item.LineComment.List { + buf.WriteByte(' ') + buf.WriteString(c.Text) + } + } buf.WriteString("\n") } buf.WriteString("}")