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.
This commit is contained in:
James Bardin 2016-07-07 15:37:57 -04:00
parent 8c741db144
commit 97316f2dae
1 changed files with 8 additions and 1 deletions

View File

@ -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
}