From b43ca0aa5270718f80029d8d857b91efc119fad0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 10 Oct 2014 10:35:34 -0700 Subject: [PATCH] providers/aws: handle case where ELB is deleted manually [GH-304] --- CHANGELOG.md | 1 + builtin/providers/aws/resource_aws_elb.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c613d9d73..f5573d024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ BUG FIXES: data. * providers/aws: ELB works properly with dynamically changing count of instances. + * providers/aws: Terraform can handle ELBs deleted manually. [GH-304] ## 0.2.2 (September 9, 2014) diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index 1418b9efe..6a483e5df 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -319,6 +319,12 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error { describeResp, err := elbconn.DescribeLoadBalancers(describeElbOpts) 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) } if len(describeResp.LoadBalancers) != 1 {