Add some additional checks
This commit is contained in:
parent
08dd7dece9
commit
120599e68f
|
@ -340,6 +340,10 @@ func resourceAzureInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
log.Printf("[DEBUG] Retrieving instance: %s", d.Id())
|
log.Printf("[DEBUG] Retrieving instance: %s", d.Id())
|
||||||
dpmt, err := virtualmachine.NewClient(mc).GetDeployment(d.Id(), d.Id())
|
dpmt, err := virtualmachine.NewClient(mc).GetDeployment(d.Id(), d.Id())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if management.IsResourceNotFoundError(err) {
|
||||||
|
d.SetId("")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return fmt.Errorf("Error retrieving instance %s: %s", d.Id(), err)
|
return fmt.Errorf("Error retrieving instance %s: %s", d.Id(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/hashcode"
|
"github.com/hashicorp/terraform/helper/hashcode"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
"github.com/svanharmelen/azure-sdk-for-go/management"
|
||||||
"github.com/svanharmelen/azure-sdk-for-go/management/networksecuritygroup"
|
"github.com/svanharmelen/azure-sdk-for-go/management/networksecuritygroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -194,6 +195,10 @@ func resourceAzureSecurityGroupRead(d *schema.ResourceData, meta interface{}) er
|
||||||
|
|
||||||
sg, err := networksecuritygroup.NewClient(mc).GetNetworkSecurityGroup(d.Id())
|
sg, err := networksecuritygroup.NewClient(mc).GetNetworkSecurityGroup(d.Id())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if management.IsResourceNotFoundError(err) {
|
||||||
|
d.SetId("")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return fmt.Errorf("Error retrieving Network Security Group %s: %s", d.Id(), err)
|
return fmt.Errorf("Error retrieving Network Security Group %s: %s", d.Id(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,6 +298,9 @@ func resourceAzureSecurityGroupRuleDelete(
|
||||||
// Delete the rule
|
// Delete the rule
|
||||||
req, err := networksecuritygroup.NewClient(mc).DeleteNetworkSecurityGroupRule(d.Id(), name)
|
req, err := networksecuritygroup.NewClient(mc).DeleteNetworkSecurityGroupRule(d.Id(), name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if management.IsResourceNotFoundError(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return fmt.Errorf("Error deleting Network Security Group rule %s: %s", name, err)
|
return fmt.Errorf("Error deleting Network Security Group rule %s: %s", name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue