providers/aws: handle case where ELB is deleted manually [GH-304]

This commit is contained in:
Mitchell Hashimoto 2014-10-10 10:35:34 -07:00
parent c5c72b1ce1
commit b43ca0aa52
2 changed files with 7 additions and 0 deletions

View File

@ -63,6 +63,7 @@ BUG FIXES:
data. data.
* providers/aws: ELB works properly with dynamically changing * providers/aws: ELB works properly with dynamically changing
count of instances. count of instances.
* providers/aws: Terraform can handle ELBs deleted manually. [GH-304]
## 0.2.2 (September 9, 2014) ## 0.2.2 (September 9, 2014)

View File

@ -319,6 +319,12 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
describeResp, err := elbconn.DescribeLoadBalancers(describeElbOpts) describeResp, err := elbconn.DescribeLoadBalancers(describeElbOpts)
if err != nil { if err != nil {
if ec2err, ok := err.(*elb.Error); ok && ec2err.Code == "LoadBalancerNotFound" {
// The ELB is gone now, so just remove it from the state
d.SetId("")
return nil
}
return fmt.Errorf("Error retrieving ELB: %s", err) return fmt.Errorf("Error retrieving ELB: %s", err)
} }
if len(describeResp.LoadBalancers) != 1 { if len(describeResp.LoadBalancers) != 1 {