From 97316f2dae591e1c16f6f6aab35e3e50e71bfc82 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 7 Jul 2016 15:37:57 -0400 Subject: [PATCH] Fix panic when there is no remote state - Check for an empty state. If nothing is referenced from that state in the config, there's nothing to do here. --- data_source_state.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/data_source_state.go b/data_source_state.go index d8c97ebd5..c87da01fb 100644 --- a/data_source_state.go +++ b/data_source_state.go @@ -55,7 +55,14 @@ func dataSourceRemoteStateRead(d *schema.ResourceData, meta interface{}) error { d.SetId(time.Now().UTC().String()) outputMap := make(map[string]interface{}) - for key, val := range state.State().RootModule().Outputs { + + remoteState := state.State() + if remoteState.Empty() { + log.Println("[DEBUG] empty remote state") + return nil + } + + for key, val := range remoteState.RootModule().Outputs { outputMap[key] = val.Value }