From 6c67b85ce6c622766576eff806d4680aa310369c Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 26 Mar 2018 10:32:34 -0400 Subject: [PATCH] resource/aws_lb_listener: Remove extraneous isListenerNotFound function --- aws/resource_aws_lb_listener.go | 8 +------- aws/resource_aws_lb_listener_test.go | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/aws/resource_aws_lb_listener.go b/aws/resource_aws_lb_listener.go index e8200f9dbec9..918d05250b0e 100644 --- a/aws/resource_aws_lb_listener.go +++ b/aws/resource_aws_lb_listener.go @@ -8,7 +8,6 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/elbv2" "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform/helper/resource" @@ -156,7 +155,7 @@ func resourceAwsLbListenerRead(d *schema.ResourceData, meta interface{}) error { ListenerArns: []*string{aws.String(d.Id())}, }) if err != nil { - if isListenerNotFound(err) { + if isAWSErr(err, elbv2.ErrCodeListenerNotFoundException, "") { log.Printf("[WARN] DescribeListeners - removing %s from state", d.Id()) d.SetId("") return nil @@ -258,11 +257,6 @@ func resourceAwsLbListenerDelete(d *schema.ResourceData, meta interface{}) error return nil } -func isListenerNotFound(err error) bool { - elberr, ok := err.(awserr.Error) - return ok && elberr.Code() == "ListenerNotFound" -} - func validateLbListenerActionType() schema.SchemaValidateFunc { return validation.StringInSlice([]string{ elbv2.ActionTypeEnumForward, diff --git a/aws/resource_aws_lb_listener_test.go b/aws/resource_aws_lb_listener_test.go index 909ad90bdb5e..a92ac57410e8 100644 --- a/aws/resource_aws_lb_listener_test.go +++ b/aws/resource_aws_lb_listener_test.go @@ -152,7 +152,7 @@ func testAccCheckAWSLBListenerDestroy(s *terraform.State) error { } // Verify the error - if isListenerNotFound(err) { + if isAWSErr(err, elbv2.ErrCodeListenerNotFoundException, "") { return nil } else { return errwrap.Wrapf("Unexpected error checking LB Listener destroyed: {{err}}", err)