Skip to content

Commit

Permalink
Fix panic when there is no remote state
Browse files Browse the repository at this point in the history
- Check for an empty state. If nothing is referenced from that state in
  the config, there's nothing to do here.
  • Loading branch information
jbardin committed Jul 7, 2016
1 parent 3622bfd commit 2c27dd4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion builtin/providers/terraform/data_source_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 2c27dd4

Please sign in to comment.