diff --git a/terraform/graph_builder_apply.go b/terraform/graph_builder_apply.go index eeda2a857..d5be10162 100644 --- a/terraform/graph_builder_apply.go +++ b/terraform/graph_builder_apply.go @@ -59,6 +59,10 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer { &ProviderTransformer{}, &ParentProviderTransformer{}, + // Provisioner-related transformations + &MissingProvisionerTransformer{Provisioners: b.Provisioners}, + &ProvisionerTransformer{}, + // Attach the configurations &AttachConfigTransformer{Module: b.Module}, diff --git a/terraform/graph_builder_apply_test.go b/terraform/graph_builder_apply_test.go index e62521d91..78c5dd61c 100644 --- a/terraform/graph_builder_apply_test.go +++ b/terraform/graph_builder_apply_test.go @@ -47,8 +47,10 @@ func TestApplyGraphBuilder(t *testing.T) { } b := &ApplyGraphBuilder{ - Diff: diff, - Providers: []string{"aws"}, + Module: testModule(t, "graph-builder-apply-basic"), + Diff: diff, + Providers: []string{"aws"}, + Provisioners: []string{"exec"}, } g, err := b.Build(RootModulePath) @@ -72,9 +74,11 @@ aws_instance.create provider.aws module.child.aws_instance.create module.child.provider.aws + provisioner.exec module.child.provider.aws provider.aws provider.aws +provisioner.exec root aws_instance.create module.child.aws_instance.create diff --git a/terraform/node_resource.go b/terraform/node_resource.go index 6373ba167..9d05d60f0 100644 --- a/terraform/node_resource.go +++ b/terraform/node_resource.go @@ -39,6 +39,23 @@ func (n *NodeApplyableResource) ProvidedBy() []string { return []string{resourceProvider(n.Addr.Type, "")} } +// GraphNodeProvisionerConsumer +func (n *NodeApplyableResource) ProvisionedBy() []string { + // If we have no configuration, then we have no provisioners + if n.Config == nil { + return nil + } + + // Build the list of provisioners we need based on the configuration. + // It is okay to have duplicates here. + result := make([]string, len(n.Config.Provisioners)) + for i, p := range n.Config.Provisioners { + result[i] = p.Type + } + + return result +} + // GraphNodeEvalable func (n *NodeApplyableResource) EvalTree() EvalNode { // stateId is the ID to put into the state diff --git a/terraform/test-fixtures/graph-builder-apply-basic/child/main.tf b/terraform/test-fixtures/graph-builder-apply-basic/child/main.tf new file mode 100644 index 000000000..e486aaa2c --- /dev/null +++ b/terraform/test-fixtures/graph-builder-apply-basic/child/main.tf @@ -0,0 +1,3 @@ +resource "aws_instance" "create" { + provisioner "exec" {} +} diff --git a/terraform/test-fixtures/graph-builder-apply-basic/main.tf b/terraform/test-fixtures/graph-builder-apply-basic/main.tf new file mode 100644 index 000000000..0f6991c53 --- /dev/null +++ b/terraform/test-fixtures/graph-builder-apply-basic/main.tf @@ -0,0 +1,3 @@ +module "child" { + source = "./child" +}