-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37902 from hashicorp/b-apigatewayv2-ConflictExcep…
…tion apigatewayv2: Retry on `ConflictException: Unable to complete operation due to concurrent modification` errors
- Loading branch information
Showing
4 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters