Class a resource that is in tfstate but unable to be found on the provider as deleted

This commit is contained in:
Brett Mack 2015-11-06 16:39:40 +00:00
parent bda4ef7e7c
commit b6abb91b83
2 changed files with 6 additions and 2 deletions

View File

@ -207,7 +207,9 @@ func resourceVcdNetworkRead(d *schema.ResourceData, meta interface{}) error {
network, err := vcd_client.OrgVdc.FindVDCNetwork(d.Id())
if err != nil {
return fmt.Errorf("Error finding network: %#v", err)
log.Printf("[DEBUG] Network no longer exists. Removing from tfstate")
d.SetId("")
return nil
}
d.Set("name", network.OrgVDCNetwork.Name)

View File

@ -355,7 +355,9 @@ func resourceVcdVAppRead(d *schema.ResourceData, meta interface{}) error {
vapp, err := vcd_client.OrgVdc.FindVAppByName(d.Id())
if err != nil {
return fmt.Errorf("Error finding vapp: %#v", err)
log.Printf("[DEBUG] Unable to find vapp. Removing from tfstate")
d.SetId("")
return nil
}
d.Set("ip", vapp.VApp.Children.VM[0].NetworkConnectionSection.NetworkConnection.IPAddress)