Skip to content

Commit

Permalink
Merge pull request #29735 from zjalicf-cyberlab/b-apigatewayv2-error-…
Browse files Browse the repository at this point in the history
…handling

fix: apigatewayv2 error handling for ConflictException: Unable to complete operation due to concurrent modification.
  • Loading branch information
ewbankkit authored Mar 10, 2023
2 parents 35d8091 + 5aed50f commit 699dd0c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/29735.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_apigatewayv2_integration: Retry errors like `ConflictException: Unable to complete operation due to concurrent modification. Please try again later.`
```
10 changes: 10 additions & 0 deletions internal/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/aws/aws-sdk-go/service/apigatewayv2"
"github.com/aws/aws-sdk-go/service/appconfig"
"github.com/aws/aws-sdk-go/service/applicationautoscaling"
"github.com/aws/aws-sdk-go/service/appsync"
Expand Down Expand Up @@ -267,6 +268,15 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS
}
})

client.apigatewayv2Conn.Handlers.Retry.PushBack(func(r *request.Request) {
// Many operations can return an error such as:
// ConflictException: Unable to complete operation due to concurrent modification. Please try again later.
// Handle them all globally for the service client.
if tfawserr.ErrMessageContains(r.Error, apigatewayv2.ErrCodeConflictException, "try again later") {
r.Retryable = aws.Bool(true)
}
})

// Workaround for https://github.com/aws/aws-sdk-go/issues/1472
client.applicationautoscalingConn.Handlers.Retry.PushBack(func(r *request.Request) {
if !strings.HasPrefix(r.Operation.Name, "Describe") && !strings.HasPrefix(r.Operation.Name, "List") {
Expand Down

0 comments on commit 699dd0c

Please sign in to comment.