From dc01633f3c8098f68d889a9b5fc8e38a17087170 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 17 Sep 2014 17:35:43 -0700 Subject: [PATCH] terraform: fixing outputs for destroy plan --- terraform/context.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/terraform/context.go b/terraform/context.go index 40761da38..2fac4d1a1 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -139,7 +139,8 @@ func (c *Context) Apply() (*State, error) { c.state.prune() // If we have no errors, then calculate the outputs if we have any - if err == nil && len(c.config.Outputs) > 0 { + root := c.state.RootModule() + if err == nil && len(c.config.Outputs) > 0 && len(root.Resources) > 0 { outputs := make(map[string]string) for _, o := range c.config.Outputs { if err = c.computeVars(o.RawConfig); err != nil { @@ -149,7 +150,7 @@ func (c *Context) Apply() (*State, error) { } // Assign the outputs to the root module - c.state.RootModule().Outputs = outputs + root.Outputs = outputs } return c.state, err