Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider: Add retry_mode parameter #31745

Merged
merged 5 commits into from
Jun 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adds retry_mode parameter to provider
  • Loading branch information
gdavison committed Jun 8, 2023
commit 675f0bc44229eef9e11a85cf2956be9a902e92d9
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ require (
github.com/hashicorp/terraform-plugin-framework-timeouts v0.3.1
github.com/hashicorp/terraform-plugin-framework-validators v0.10.0
github.com/hashicorp/terraform-plugin-go v0.15.0
github.com/hashicorp/terraform-plugin-log v0.8.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.10.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
github.com/hashicorp/terraform-plugin-testing v1.2.0
@@ -153,3 +153,7 @@ require (
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/hashicorp/aws-sdk-go-base/v2 => github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.28.0.20230601235955-fdaff327478c

replace github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 => github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.29.0.20230601235955-fdaff327478c
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -185,10 +185,10 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/aws-cloudformation-resource-schema-sdk-go v0.20.0 h1:xc1OYpWvNo6dhnzemfjwtbNxeu3Ag4Wr6yT8BOo0/q0=
github.com/hashicorp/aws-cloudformation-resource-schema-sdk-go v0.20.0/go.mod h1:cdTE6F2pCKQobug+RqRaQp7Kz9hIEqiSvpPmb6E5G1w=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.28 h1:ZPi6zWIkChrz2A/UuY6uW+a/f/Q/YYfsRGgrimN2T0Y=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.28/go.mod h1:SrGbQeiwYYJN8R0ZZcDHXI2D3nxjPxa3J/dOD44zth0=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.29 h1:+jnBsCje/ZAQn3wCuNZxo+SUxCFK0Tqvsvy5X0hYBGw=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.29/go.mod h1:1GZMKOuoyvKRAGz2YkjYSvUgnNH7WQwH659t8ybjskU=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.28.0.20230601235955-fdaff327478c h1:B1marlEGY360n2sg1B0dY8X53tbbXtl2VWTs8iZLVyk=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.28.0.20230601235955-fdaff327478c/go.mod h1:pXMVV3iVDYV8+mw3nj6w8Q7je6foaeHGdXwpqGNh4+Y=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.29.0.20230601235955-fdaff327478c h1:HGku/W7wUqpexqSZBOX9Vq1ttDlJ26YVs8/B+rymBu4=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.29.0.20230601235955-fdaff327478c/go.mod h1:1GZMKOuoyvKRAGz2YkjYSvUgnNH7WQwH659t8ybjskU=
github.com/hashicorp/awspolicyequivalence v1.6.0 h1:7aadmkalbc5ewStC6g3rljx1iNvP4QyAhg2KsHx8bU8=
github.com/hashicorp/awspolicyequivalence v1.6.0/go.mod h1:9IOaIHx+a7C0NfUNk1A93M7kHd5rJ19aoUx37LZGC14=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -231,8 +231,8 @@ github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 h1:4L0tmy/8es
github.com/hashicorp/terraform-plugin-framework-validators v0.10.0/go.mod h1:qdQJCdimB9JeX2YwOpItEu+IrfoJjWQ5PhLpAOMDQAE=
github.com/hashicorp/terraform-plugin-go v0.15.0 h1:1BJNSUFs09DS8h/XNyJNJaeusQuWc/T9V99ylU9Zwp0=
github.com/hashicorp/terraform-plugin-go v0.15.0/go.mod h1:tk9E3/Zx4RlF/9FdGAhwxHExqIHHldqiQGt20G6g+nQ=
github.com/hashicorp/terraform-plugin-log v0.8.0 h1:pX2VQ/TGKu+UU1rCay0OlzosNKe4Nz1pepLXj95oyy0=
github.com/hashicorp/terraform-plugin-log v0.8.0/go.mod h1:1myFrhVsBLeylQzYYEV17VVjtG8oYPRFdaZs7xdW2xs=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-mux v0.10.0 h1:VejY1BffxGy2iYOaa8DDHavY4k9jbvAE8F3lhruspKY=
github.com/hashicorp/terraform-plugin-mux v0.10.0/go.mod h1:9sdnpmY20xIsl4ItsfODZYE+MgpSy/osXpSf+RwaZCY=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 h1:G9WAfb8LHeCxu7Ae8nc1agZlQOSCUWsb610iAogBhCs=
3 changes: 3 additions & 0 deletions internal/conns/config.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"log"
"strings"

awsv2 "github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
"github.com/aws/aws-sdk-go-v2/service/route53domains"
"github.com/aws/aws-sdk-go/aws"
@@ -63,6 +64,7 @@ type Config struct {
MaxRetries int
Profile string
Region string
RetryMode awsv2.RetryMode
S3UsePathStyle bool
SecretKey string
SharedConfigFiles []string
@@ -94,6 +96,7 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS
MaxRetries: c.MaxRetries,
Profile: c.Profile,
Region: c.Region,
RetryMode: c.RetryMode,
SecretKey: c.SecretKey,
SkipCredsValidation: c.SkipCredsValidation,
SkipRequestingAccountId: c.SkipRequestingAccountId,
4 changes: 4 additions & 0 deletions internal/provider/fwprovider/provider.go
Original file line number Diff line number Diff line change
@@ -84,6 +84,10 @@ func (p *fwprovider) Schema(ctx context.Context, req provider.SchemaRequest, res
Optional: true,
Description: "The region where AWS operations will take place. Examples\nare us-east-1, us-west-2, etc.", // lintignore:AWSAT003
},
"retry_mode": schema.StringAttribute{
Optional: true,
Description: "Specifies how retries are attempted. Valid values are `standard` and `adaptive`. Can also be configured using the `RETRY_MODE` environment variable.",
},
"s3_use_path_style": schema.BoolAttribute{
Optional: true,
Description: "Set this to true to enable the request to use path-style addressing,\ni.e., https://s3.amazonaws.com/BUCKET/KEY. By default, the S3 client will\nuse virtual hosted bucket addressing when possible\n(https://BUCKET.s3.amazonaws.com/KEY). Specific to the Amazon S3 service.",
15 changes: 15 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import (
"regexp"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
awsbase "github.com/hashicorp/aws-sdk-go-base/v2"
multierror "github.com/hashicorp/go-multierror"
@@ -143,6 +144,12 @@ func New(ctx context.Context) (*schema.Provider, error) {
Description: "The region where AWS operations will take place. Examples\n" +
"are us-east-1, us-west-2, etc.", // lintignore:AWSAT003,
},
"retry_mode": {
Type: schema.TypeString,
Optional: true,
Description: "Specifies how retries are attempted. Valid values are `standard` and `adaptive`. " +
"Can also be configured using the `RETRY_MODE` environment variable.",
},
"s3_use_path_style": {
Type: schema.TypeBool,
Optional: true,
@@ -434,6 +441,14 @@ func configure(ctx context.Context, provider *schema.Provider, d *schema.Resourc
UseFIPSEndpoint: d.Get("use_fips_endpoint").(bool),
}

if v, ok := d.Get("retry_mode").(string); ok && v != "" {
mode, err := aws.ParseRetryMode(v)
if err != nil {
return nil, diag.FromErr(err)
}
config.RetryMode = mode
}

if v, ok := d.GetOk("allowed_account_ids"); ok && v.(*schema.Set).Len() > 0 {
config.AllowedAccountIds = flex.ExpandStringValueSet(v.(*schema.Set))
}