From 07c6c656951d455631d27c7835dd8cf5543b49cf Mon Sep 17 00:00:00 2001 From: Puneeth Nanjundaswamy Date: Thu, 11 Jan 2018 16:51:45 +0100 Subject: [PATCH] make rate limit errors retryable --- aws/resource_aws_lambda_function.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_lambda_function.go b/aws/resource_aws_lambda_function.go index d16988346c6..efd3ee7c177 100644 --- a/aws/resource_aws_lambda_function.go +++ b/aws/resource_aws_lambda_function.go @@ -639,10 +639,24 @@ func resourceAwsLambdaFunctionUpdate(d *schema.ResourceData, meta interface{}) e if configUpdate { log.Printf("[DEBUG] Send Update Lambda Function Configuration request: %#v", configReq) - _, err := conn.UpdateFunctionConfiguration(configReq) + + err := resource.Retry(10*time.Minute, func() *resource.RetryError { + _, err := conn.UpdateFunctionConfiguration(configReq) + if err != nil { + log.Printf("[DEBUG] Received error modifying Lambda Function Configuration %s: %s", d.Id(), err) + + if isAWSErr(err, "InvalidParameterValueException", "Your request has been throttled by EC2, please make sure you have enough API rate limit.") { + log.Printf("[DEBUG] Received %s, retrying UpdateFunctionConfiguration", err) + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) if err != nil { return fmt.Errorf("Error modifying Lambda Function Configuration %s: %s", d.Id(), err) } + d.SetPartial("description") d.SetPartial("handler") d.SetPartial("memory_size")