From 7fd432b0764b8737875c71d0d70e5480e6073927 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 1 May 2015 16:41:49 -0700 Subject: [PATCH] terraform: providers in flattened graphs should depend on the parent --- terraform/graph_config_node_provider.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/terraform/graph_config_node_provider.go b/terraform/graph_config_node_provider.go index 5b8fb1bcb..c0e15eff3 100644 --- a/terraform/graph_config_node_provider.go +++ b/terraform/graph_config_node_provider.go @@ -102,10 +102,26 @@ func (n *GraphNodeConfigProviderFlat) DependableName() []string { } func (n *GraphNodeConfigProviderFlat) DependentOn() []string { - prefix := modulePrefixStr(n.PathValue) - return modulePrefixList( + prefixed := modulePrefixList( n.GraphNodeConfigProvider.DependentOn(), - prefix) + modulePrefixStr(n.PathValue)) + + result := make([]string, len(prefixed), len(prefixed)+1) + copy(result, prefixed) + + // If we're in a module, then depend on our parent's provider + if len(n.PathValue) > 1 { + prefix := modulePrefixStr(n.PathValue[:len(n.PathValue)-1]) + if prefix != "" { + prefix += "." + } + + result = append(result, fmt.Sprintf( + "%s%s", + prefix, n.GraphNodeConfigProvider.Name())) + } + + return result } func (n *GraphNodeConfigProviderFlat) ProviderName() string {