providers/aws: use isLoadBalancerNotFound

This commit is contained in:
TANABE Ken-ichi 2015-04-30 01:31:23 +09:00
parent 5c1dabdb69
commit 9df2bf68cb
2 changed files with 10 additions and 5 deletions

View File

@ -243,7 +243,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
describeResp, err := elbconn.DescribeLoadBalancers(describeElbOpts)
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
d.SetId("")
return nil
@ -260,7 +260,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
}
describeAttrsResp, err := elbconn.DescribeLoadBalancerAttributes(describeAttrsOpts)
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
d.SetId("")
return nil
@ -502,3 +502,8 @@ func resourceAwsElbListenerHash(v interface{}) int {
return hashcode.String(buf.String())
}
func isLoadBalancerNotFound(err error) bool {
elberr, ok := err.(aws.APIError)
return ok && elberr.Code == "LoadBalancerNotFound"
}

View File

@ -81,7 +81,7 @@ func resourceAwsProxyProtocolPolicyRead(d *schema.ResourceData, meta interface{}
}
resp, err := elbconn.DescribeLoadBalancers(req)
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
d.SetId("")
return nil
@ -111,7 +111,7 @@ func resourceAwsProxyProtocolPolicyUpdate(d *schema.ResourceData, meta interface
}
resp, err := elbconn.DescribeLoadBalancers(req)
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
d.SetId("")
return nil
@ -167,7 +167,7 @@ func resourceAwsProxyProtocolPolicyDelete(d *schema.ResourceData, meta interface
}
resp, err := elbconn.DescribeLoadBalancers(req)
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
d.SetId("")
return nil