From 037d4b6c877d6bd53089f77dcf10130c7c6f02a2 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Tue, 31 Jan 2017 15:12:11 -0800 Subject: [PATCH 1/2] Suggest refresh instead of apply Suggesting an apply could actually change remote resources whereas a refresh will at-worst modify local state. --- command/output.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/output.go b/command/output.go index 44e6932e1..65cc133bf 100644 --- a/command/output.go +++ b/command/output.go @@ -79,7 +79,7 @@ func (c *OutputCommand) Run(args []string) int { c.Ui.Error(fmt.Sprintf( "The state file has no outputs defined. Define an output\n" + "in your configuration with the `output` directive and re-run\n" + - "`terraform apply` for it to become available.")) + "`terraform refresh` for it to become available.")) return 1 } From 0d39123cb0cf052379204bf2a33782c83451aef2 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Tue, 31 Jan 2017 15:20:11 -0800 Subject: [PATCH 2/2] Update error message when no outputs are defined Terraform can't tell the difference between an empty output and an undefined output. This is often confusing for folks using interpolation. As much as it would be great to fix upstream, changing this error message to be a bit more helpful is a good stop-gap to avoid frustration. --- command/output.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/command/output.go b/command/output.go index 65cc133bf..627b0dcb9 100644 --- a/command/output.go +++ b/command/output.go @@ -76,10 +76,13 @@ func (c *OutputCommand) Run(args []string) int { } if state.Empty() || len(mod.Outputs) == 0 { - c.Ui.Error(fmt.Sprintf( - "The state file has no outputs defined. Define an output\n" + - "in your configuration with the `output` directive and re-run\n" + - "`terraform refresh` for it to become available.")) + c.Ui.Error( + "The state file either has no outputs defined, or all the defined\n" + + "outputs are empty. Please define an output in your configuration\n" + + "with the `output` keyword and run `terraform refresh` for it to\n" + + "become available. If you are using interpolation, please verify\n" + + "the interpolated value is not empty. You can use the \n" + + "`terraform console` command to assist.") return 1 }