From 6eb0bd2f2377ae6818f627dceefa7e6a22733824 Mon Sep 17 00:00:00 2001 From: Gideon Seyetik Date: Sun, 14 Oct 2018 14:24:30 -0400 Subject: [PATCH] Add eventual consistent read for elbv2 listener rule. --- aws/resource_aws_lb_listener_rule.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_lb_listener_rule.go b/aws/resource_aws_lb_listener_rule.go index cbfab8d8458..5f44fa8c887 100644 --- a/aws/resource_aws_lb_listener_rule.go +++ b/aws/resource_aws_lb_listener_rule.go @@ -508,9 +508,24 @@ func resourceAwsLbListenerRuleCreate(d *schema.ResourceData, meta interface{}) e func resourceAwsLbListenerRuleRead(d *schema.ResourceData, meta interface{}) error { elbconn := meta.(*AWSClient).elbv2conn - resp, err := elbconn.DescribeRules(&elbv2.DescribeRulesInput{ + var resp *elbv2.DescribeRulesOutput + var req = &elbv2.DescribeRulesInput{ RuleArns: []*string{aws.String(d.Id())}, + } + + err := resource.Retry(1*time.Minute, func() *resource.RetryError { + var err error + resp, err = elbconn.DescribeRules(req) + if err != nil { + if d.IsNewResource() && isAWSErr(err, elbv2.ErrCodeRuleNotFoundException, "") { + return resource.RetryableError(err) + } else { + return resource.NonRetryableError(err) + } + } + return nil }) + if err != nil { if isAWSErr(err, elbv2.ErrCodeRuleNotFoundException, "") { log.Printf("[WARN] DescribeRules - removing %s from state", d.Id())