providers/aws: use isLoadBalancerNotFound
This commit is contained in:
parent
5c1dabdb69
commit
9df2bf68cb
|
@ -243,7 +243,7 @@ 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.(aws.APIError); ok && ec2err.Code == "LoadBalancerNotFound" {
|
if isLoadBalancerNotFound(err) {
|
||||||
// The ELB is gone now, so just remove it from the state
|
// The ELB is gone now, so just remove it from the state
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
|
@ -260,7 +260,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
describeAttrsResp, err := elbconn.DescribeLoadBalancerAttributes(describeAttrsOpts)
|
describeAttrsResp, err := elbconn.DescribeLoadBalancerAttributes(describeAttrsOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "LoadBalancerNotFound" {
|
if isLoadBalancerNotFound(err) {
|
||||||
// The ELB is gone now, so just remove it from the state
|
// The ELB is gone now, so just remove it from the state
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
|
@ -502,3 +502,8 @@ func resourceAwsElbListenerHash(v interface{}) int {
|
||||||
|
|
||||||
return hashcode.String(buf.String())
|
return hashcode.String(buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isLoadBalancerNotFound(err error) bool {
|
||||||
|
elberr, ok := err.(aws.APIError)
|
||||||
|
return ok && elberr.Code == "LoadBalancerNotFound"
|
||||||
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ func resourceAwsProxyProtocolPolicyRead(d *schema.ResourceData, meta interface{}
|
||||||
}
|
}
|
||||||
resp, err := elbconn.DescribeLoadBalancers(req)
|
resp, err := elbconn.DescribeLoadBalancers(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "LoadBalancerNotFound" {
|
if isLoadBalancerNotFound(err) {
|
||||||
// The ELB is gone now, so just remove it from the state
|
// The ELB is gone now, so just remove it from the state
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
|
@ -111,7 +111,7 @@ func resourceAwsProxyProtocolPolicyUpdate(d *schema.ResourceData, meta interface
|
||||||
}
|
}
|
||||||
resp, err := elbconn.DescribeLoadBalancers(req)
|
resp, err := elbconn.DescribeLoadBalancers(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "LoadBalancerNotFound" {
|
if isLoadBalancerNotFound(err) {
|
||||||
// The ELB is gone now, so just remove it from the state
|
// The ELB is gone now, so just remove it from the state
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
|
@ -167,7 +167,7 @@ func resourceAwsProxyProtocolPolicyDelete(d *schema.ResourceData, meta interface
|
||||||
}
|
}
|
||||||
resp, err := elbconn.DescribeLoadBalancers(req)
|
resp, err := elbconn.DescribeLoadBalancers(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "LoadBalancerNotFound" {
|
if isLoadBalancerNotFound(err) {
|
||||||
// The ELB is gone now, so just remove it from the state
|
// The ELB is gone now, so just remove it from the state
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue