From f97c635ef66d8ab53205f7956138e73428b692b4 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 16 Jul 2015 11:56:58 -0500 Subject: [PATCH] core: fix "provider ... couldn't be found" bug The `CloseProviderTransformer` relies on the `ProvidedBy()` interface to look up the proper dependency for the the graph nodes it adds. This interface needs to yield the name of a provider, _AND_ for flattened nodes it needs to yield the full path to a provider. Destroy nodes did not implement this second part, which resulted in "provider X couldn't be found" when both of these were true: * A module included a resource that dependend on a provider * The root did _NOT_ include a provider config Implementing a proper ProvidedBy() on the flattened version of destroy nodes solves the issue. fixes #2581 --- terraform/graph_config_node_resource.go | 7 +++++++ terraform/transform_provider.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/terraform/graph_config_node_resource.go b/terraform/graph_config_node_resource.go index 936398d2a..2235f4925 100644 --- a/terraform/graph_config_node_resource.go +++ b/terraform/graph_config_node_resource.go @@ -335,6 +335,13 @@ func (n *graphNodeResourceDestroyFlat) CreateNode() dag.Vertex { return n.FlatCreateNode } +func (n *graphNodeResourceDestroyFlat) ProvidedBy() []string { + prefix := modulePrefixStr(n.PathValue) + return modulePrefixList( + n.GraphNodeConfigResource.ProvidedBy(), + prefix) +} + // graphNodeResourceDestroy represents the logical destruction of a // resource. This node doesn't mean it will be destroyed for sure, but // instead that if a destroy were to happen, it must happen at this point. diff --git a/terraform/transform_provider.go b/terraform/transform_provider.go index fb8857c96..8a6655182 100644 --- a/terraform/transform_provider.go +++ b/terraform/transform_provider.go @@ -130,7 +130,7 @@ func (t *CloseProviderTransformer) Transform(g *Graph) error { provider, ok := pm[p] if !ok { err = multierror.Append(err, fmt.Errorf( - "%s: provider %s couldn't be found", + "%s: provider %s couldn't be found for closing", dag.VertexName(v), p)) continue }