diff --git a/aws/resource_aws_lb_listener.go b/aws/resource_aws_lb_listener.go index 14ae1b2abc6..98d93be9dcc 100644 --- a/aws/resource_aws_lb_listener.go +++ b/aws/resource_aws_lb_listener.go @@ -26,6 +26,10 @@ func resourceAwsLbListener() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "arn": { Type: schema.TypeString, @@ -516,11 +520,26 @@ func resourceAwsLbListenerCreate(d *schema.ResourceData, meta interface{}) error func resourceAwsLbListenerRead(d *schema.ResourceData, meta interface{}) error { elbconn := meta.(*AWSClient).elbv2conn - resp, err := elbconn.DescribeListeners(&elbv2.DescribeListenersInput{ + var resp *elbv2.DescribeListenersOutput + var request = &elbv2.DescribeListenersInput{ ListenerArns: []*string{aws.String(d.Id())}, + } + + err := resource.Retry(d.Timeout(schema.TimeoutRead), func() *resource.RetryError { + var err error + resp, err = elbconn.DescribeListeners(request) + if err != nil { + if d.IsNewResource() && isAWSErr(err, elbv2.ErrCodeListenerNotFoundException, "") { + return resource.RetryableError(err) + } else { + return resource.NonRetryableError(err) + } + } + return nil }) + if err != nil { - if isAWSErr(err, elbv2.ErrCodeListenerNotFoundException, "") { + if !d.IsNewResource() && isAWSErr(err, elbv2.ErrCodeListenerNotFoundException, "") { log.Printf("[WARN] DescribeListeners - removing %s from state", d.Id()) d.SetId("") return nil