diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 9965897fc..a052328d1 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -2583,6 +2583,13 @@ func TestContext2Apply_moduleDestroyOrder(t *testing.T) { info *InstanceInfo, is *InstanceState, id *InstanceDiff) (*InstanceState, error) { + + if is.ID == "b" { + // Pause briefly to make any race conditions more visible, since + // missing edges here can cause undeterministic ordering. + time.Sleep(100 * time.Millisecond) + } + orderLock.Lock() defer orderLock.Unlock() @@ -2590,6 +2597,18 @@ func TestContext2Apply_moduleDestroyOrder(t *testing.T) { return nil, nil } + p.GetSchemaReturn = &ProviderSchema{ + ResourceTypes: map[string]*configschema.Block{ + "aws_instance": { + Attributes: map[string]*configschema.Attribute{ + "id": {Type: cty.String, Required: true}, + "blah": {Type: cty.String, Optional: true}, + "value": {Type: cty.String, Optional: true}, + }, + }, + }, + } + state := mustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ diff --git a/terraform/test-fixtures/apply-module-destroy-order/child/main.tf b/terraform/test-fixtures/apply-module-destroy-order/child/main.tf index c3a5aecd6..0b2a8bc07 100644 --- a/terraform/test-fixtures/apply-module-destroy-order/child/main.tf +++ b/terraform/test-fixtures/apply-module-destroy-order/child/main.tf @@ -1,5 +1,7 @@ -resource "aws_instance" "a" {} +resource "aws_instance" "a" { + id = "a" +} output "a_output" { - value = "${aws_instance.a.id}" + value = "${aws_instance.a.id}" } diff --git a/terraform/test-fixtures/apply-module-destroy-order/main.tf b/terraform/test-fixtures/apply-module-destroy-order/main.tf index 2a6bcce37..2c47edadf 100644 --- a/terraform/test-fixtures/apply-module-destroy-order/main.tf +++ b/terraform/test-fixtures/apply-module-destroy-order/main.tf @@ -3,5 +3,6 @@ module "child" { } resource "aws_instance" "b" { - blah = "${module.child.a_output}" + id = "b" + blah = "${module.child.a_output}" }