Skip to content

Commit

Permalink
Merge pull request #23879 from hashicorp/add-retry-for-lambda-update-…
Browse files Browse the repository at this point in the history
…conflict

r/lambda_function: add `ResourceConflictException` error handling on create and update
  • Loading branch information
anGie44 authored Mar 25, 2022
2 parents 1af230d + 41b833f commit 30cb070
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/23879.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_lambda_function: Add error handling for `ResourceConflictException` errors on create and update
```
10 changes: 10 additions & 0 deletions internal/service/lambda/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,11 @@ func resourceFunctionCreate(d *schema.ResourceData, meta interface{}) error {
return resource.RetryableError(err)
}

if tfawserr.ErrCodeEquals(err, lambda.ErrCodeResourceConflictException) {
log.Printf("[DEBUG] Received %s, retrying CreateFunction", err)
return resource.RetryableError(err)
}

if err != nil {
return resource.NonRetryableError(err)
}
Expand Down Expand Up @@ -1136,6 +1141,11 @@ func resourceFunctionUpdate(d *schema.ResourceData, meta interface{}) error {
return resource.RetryableError(err)
}

if tfawserr.ErrCodeEquals(err, lambda.ErrCodeResourceConflictException) {
log.Printf("[DEBUG] Received %s, retrying UpdateFunctionConfiguration", err)
return resource.RetryableError(err)
}

if err != nil {
return resource.NonRetryableError(err)
}
Expand Down

0 comments on commit 30cb070

Please sign in to comment.