Skip to content

Commit

Permalink
Merge pull request #37902 from hashicorp/b-apigatewayv2-ConflictExcep…
Browse files Browse the repository at this point in the history
…tion

apigatewayv2: Retry on `ConflictException: Unable to complete operation due to concurrent modification` errors
  • Loading branch information
ewbankkit authored Jun 10, 2024
2 parents 210effc + 4a19667 commit 148c46d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .changelog/37902.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
service/apigatewayv2: Retry on `ConflictException: Unable to complete operation due to concurrent modification` errors
```
43 changes: 43 additions & 0 deletions internal/service/apigatewayv2/service_package.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package apigatewayv2

import (
"context"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/service/apigatewayv2"
awstypes "github.com/aws/aws-sdk-go-v2/service/apigatewayv2/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
"github.com/hashicorp/terraform-provider-aws/names"
)

// NewClient returns a new AWS SDK for Go v2 client for this service package's AWS API.
func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*apigatewayv2.Client, error) {
cfg := *(config["aws_sdkv2_config"].(*aws.Config))

return apigatewayv2.NewFromConfig(cfg, func(o *apigatewayv2.Options) {
if endpoint := config[names.AttrEndpoint].(string); endpoint != "" {
tflog.Debug(ctx, "setting endpoint", map[string]any{
"tf_aws.endpoint": endpoint,
})
o.BaseEndpoint = aws.String(endpoint)

if o.EndpointOptions.UseFIPSEndpoint == aws.FIPSEndpointStateEnabled {
tflog.Debug(ctx, "endpoint set, ignoring UseFIPSEndpoint setting")
o.EndpointOptions.UseFIPSEndpoint = aws.FIPSEndpointStateDisabled
}
}

o.Retryer = conns.AddIsErrorRetryables(cfg.Retryer().(aws.RetryerV2), retry.IsErrorRetryableFunc(func(err error) aws.Ternary {
if errs.IsAErrorMessageContains[*awstypes.ConflictException](err, "try again later") {
return aws.TrueTernary
}
return aws.UnknownTernary // Delegate to configured Retryer.
}))
}), nil
}
22 changes: 0 additions & 22 deletions internal/service/apigatewayv2/service_package_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion names/data/names_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ amplifyuibuilder,amplifyuibuilder,amplifyuibuilder,amplifyuibuilder,,amplifyuibu
,,,,,,,,,,,,,,,,,Apache MXNet on AWS,AWS,x,,,,,,,,,,Documentation
apigateway,apigateway,apigateway,apigateway,,apigateway,,,APIGateway,APIGateway,x,,2,aws_api_gateway_,aws_apigateway_,,api_gateway_,API Gateway,Amazon,,,,,,,API Gateway,GetAccount,,,
apigatewaymanagementapi,apigatewaymanagementapi,apigatewaymanagementapi,apigatewaymanagementapi,,apigatewaymanagementapi,,,APIGatewayManagementAPI,ApiGatewayManagementApi,,1,,,aws_apigatewaymanagementapi_,,apigatewaymanagementapi_,API Gateway Management API,Amazon,,x,,,,,ApiGatewayManagementApi,,,,
apigatewayv2,apigatewayv2,apigatewayv2,apigatewayv2,,apigatewayv2,,,APIGatewayV2,ApiGatewayV2,,,2,,aws_apigatewayv2_,,apigatewayv2_,API Gateway V2,Amazon,,,,,,,ApiGatewayV2,GetApis,,,
apigatewayv2,apigatewayv2,apigatewayv2,apigatewayv2,,apigatewayv2,,,APIGatewayV2,ApiGatewayV2,x,,2,,aws_apigatewayv2_,,apigatewayv2_,API Gateway V2,Amazon,,,,,,,ApiGatewayV2,GetApis,,,
appfabric,appfabric,appfabric,appfabric,,appfabric,,,AppFabric,AppFabric,,,2,,aws_appfabric_,,appfabric_,AppFabric,AWS,,,,,,,AppFabric,ListAppBundles,,,
appmesh,appmesh,appmesh,appmesh,,appmesh,,,AppMesh,AppMesh,,1,,,aws_appmesh_,,appmesh_,App Mesh,AWS,,,,,,,App Mesh,ListMeshes,,,
apprunner,apprunner,apprunner,apprunner,,apprunner,,,AppRunner,AppRunner,,,2,,aws_apprunner_,,apprunner_,App Runner,AWS,,,,,,,AppRunner,ListConnections,,,
Expand Down

0 comments on commit 148c46d

Please sign in to comment.