diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 0fc33f699..58c61a393 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -7725,6 +7725,10 @@ func TestContext2Apply_destroyProvisionerWithMultipleLocals(t *testing.T) { pr.GetSchemaResponse = provisioners.GetSchemaResponse{ Provisioner: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ + "id": { + Type: cty.String, + Required: true, + }, "command": { Type: cty.String, Required: true, @@ -7742,8 +7746,12 @@ func TestContext2Apply_destroyProvisionerWithMultipleLocals(t *testing.T) { if !ok { return errors.New("no command in provisioner") } + id, ok := rc.Get("id") + if !ok { + return errors.New("no id in provisioner") + } - switch is.ID { + switch id { case "1234": if cmd != "local" { return fmt.Errorf("provisioner %q got:%q", is.ID, cmd) diff --git a/terraform/test-fixtures/apply-provisioner-destroy-multiple-locals/main.tf b/terraform/test-fixtures/apply-provisioner-destroy-multiple-locals/main.tf index 437a6e727..2050b19a1 100644 --- a/terraform/test-fixtures/apply-provisioner-destroy-multiple-locals/main.tf +++ b/terraform/test-fixtures/apply-provisioner-destroy-multiple-locals/main.tf @@ -1,24 +1,26 @@ locals { - value = "local" - foo_id = "${aws_instance.foo.id}" + value = "local" + foo_id = aws_instance.foo.id // baz is not in the state during destroy, but this is a valid config that // should not fail. - baz_id = "${aws_instance.baz.id}" + baz_id = aws_instance.baz.id } resource "aws_instance" "baz" {} resource "aws_instance" "foo" { - provisioner "shell" { - command = "${local.value}" - when = "destroy" - } + provisioner "shell" { + id = self.id + command = local.value + when = "destroy" + } } resource "aws_instance" "bar" { - provisioner "shell" { - command = "${local.foo_id}" - when = "destroy" - } + provisioner "shell" { + id = self.id + command = local.foo_id + when = "destroy" + } }