diff --git a/configs/configupgrade/test-fixtures/valid/noop/input/resources.tf b/configs/configupgrade/test-fixtures/valid/noop/input/resources.tf index e8210aa23..f738f6971 100644 --- a/configs/configupgrade/test-fixtures/valid/noop/input/resources.tf +++ b/configs/configupgrade/test-fixtures/valid/noop/input/resources.tf @@ -1,3 +1,11 @@ resource "test_instance" "example" { + connection { + host = "127.0.0.1" + } + provisioner "local-exec" { + connection { + host = "127.0.0.2" + } + } } diff --git a/configs/configupgrade/test-fixtures/valid/noop/want/resources.tf b/configs/configupgrade/test-fixtures/valid/noop/want/resources.tf index e8210aa23..f738f6971 100644 --- a/configs/configupgrade/test-fixtures/valid/noop/want/resources.tf +++ b/configs/configupgrade/test-fixtures/valid/noop/want/resources.tf @@ -1,3 +1,11 @@ resource "test_instance" "example" { + connection { + host = "127.0.0.1" + } + provisioner "local-exec" { + connection { + host = "127.0.0.2" + } + } } diff --git a/configs/configupgrade/upgrade_native.go b/configs/configupgrade/upgrade_native.go index 009d44cf6..2e8d91fe0 100644 --- a/configs/configupgrade/upgrade_native.go +++ b/configs/configupgrade/upgrade_native.go @@ -329,6 +329,24 @@ func (u *Upgrader) upgradeNativeSyntaxResource(filename string, buf *bytes.Buffe rules["depends_on"] = dependsOnAttributeRule(filename, an) rules["provider"] = maybeBareTraversalAttributeRule(filename, an) rules["lifecycle"] = nestedBlockRule(filename, lifecycleBlockBodyRules(filename, an), an, adhocComments) + rules["connection"] = func(buf *bytes.Buffer, blockAddr string, item *hcl1ast.ObjectItem) tfdiags.Diagnostics { + // TODO: For the few resource types that were setting ConnInfo in + // state after create/update in prior versions, generate the additional + // explicit connection settings that are now required if and only if + // there's at least one provisioner block. + // For now, we just pass this through as-is. + hcl1printer.Fprint(buf, item) + buf.WriteByte('\n') + return nil + } + rules["provisioner"] = func(buf *bytes.Buffer, blockAddr string, item *hcl1ast.ObjectItem) tfdiags.Diagnostics { + // TODO: Look up the provisioner schema and map this properly to ensure + // any references get properly updated. + // For now, we just pass this through as-is. + hcl1printer.Fprint(buf, item) + buf.WriteByte('\n') + return nil + } printComments(buf, item.LeadComment) printBlockOpen(buf, blockType, labels, item.LineComment)