Fixing the digitalocean floatingip resource for a panic when droplet wasn't available

This commit is contained in:
stack72 2015-12-08 16:29:13 +00:00
parent 4b749d1137
commit 28a627a0ac
1 changed files with 4 additions and 2 deletions

View File

@ -83,8 +83,10 @@ func resourceDigitalOceanFloatingIpRead(d *schema.ResourceData, meta interface{}
}
if _, ok := d.GetOk("droplet_id"); ok {
log.Printf("[INFO] The region of the Droplet is %s", floatingIp.Droplet.Region)
d.Set("region", floatingIp.Droplet.Region.Slug)
if floatingIp.Droplet != nil {
log.Printf("[INFO] The region of the Droplet is %s", floatingIp.Droplet.Region)
d.Set("region", floatingIp.Droplet.Region.Slug)
}
} else {
d.Set("region", floatingIp.Region.Slug)
}