Skip to content

Commit

Permalink
Merge pull request #3570 from terraform-providers/b-aws_lambda_functi…
Browse files Browse the repository at this point in the history
…on-concurrency-retries

resource/aws_lambda_function: Allow PutFunctionConcurrency retries on creation
  • Loading branch information
bflad authored Mar 6, 2018
2 parents 667545c + 98e042b commit 52b2fcc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions aws/resource_aws_lambda_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error creating Lambda function: %s", err)
}

d.SetId(d.Get("function_name").(string))

if reservedConcurrentExecutions > 0 {

log.Printf("[DEBUG] Setting Concurrency to %d for the Lambda Function %s", reservedConcurrentExecutions, functionName)
Expand All @@ -387,14 +389,21 @@ func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) e
ReservedConcurrentExecutions: aws.Int64(int64(reservedConcurrentExecutions)),
}

_, err := conn.PutFunctionConcurrency(concurrencyParams)
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := conn.PutFunctionConcurrency(concurrencyParams)
if err != nil {
if isAWSErr(err, lambda.ErrCodeResourceNotFoundException, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
return fmt.Errorf("Error setting concurrency for Lambda %s: %s", functionName, err)
}
}

d.SetId(d.Get("function_name").(string))

return resourceAwsLambdaFunctionRead(d, meta)
}

Expand Down

0 comments on commit 52b2fcc

Please sign in to comment.