Skip to content

Commit

Permalink
Merge pull request #31745 from hashicorp/f-retry-mode
Browse files Browse the repository at this point in the history
provider: Add `retry_mode` parameter
  • Loading branch information
gdavison authored Jun 8, 2023
2 parents f28467c + 2ca7e17 commit 643a025
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .changelog/31745.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
provider: Adds `retry_mode` parameter
```
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/ProtonMail/go-crypto v0.0.0-20230201104953-d1d05f4e2bfb
github.com/aws/aws-sdk-go v1.44.277
github.com/aws/aws-sdk-go v1.44.278
github.com/aws/aws-sdk-go-v2 v1.18.0
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.19.12
Expand Down Expand Up @@ -52,8 +52,8 @@ require (
github.com/beevik/etree v1.2.0
github.com/google/go-cmp v0.5.9
github.com/hashicorp/aws-cloudformation-resource-schema-sdk-go v0.20.0
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.28
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.29
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.29
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.30
github.com/hashicorp/awspolicyequivalence v1.6.0
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
Expand All @@ -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
Expand Down Expand Up @@ -99,7 +99,7 @@ require (
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect
github.com/aws/aws-sdk-go-v2/service/iam v1.19.12 // indirect
github.com/aws/aws-sdk-go-v2/service/iam v1.20.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go v1.44.277 h1:YHmyzBPARTJ7LLYV1fxbfEbQOaUh3kh52hb7nBvX3BQ=
github.com/aws/aws-sdk-go v1.44.277/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.44.278 h1:jJFDO/unYFI48WQk7UGSyO3rBA/gnmRpNYNuAw/fPgE=
github.com/aws/aws-sdk-go v1.44.278/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY=
github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs=
Expand Down Expand Up @@ -71,8 +71,8 @@ github.com/aws/aws-sdk-go-v2/service/glacier v1.14.11 h1:dTa4Macg5HxqrQfauBnhpx5
github.com/aws/aws-sdk-go-v2/service/glacier v1.14.11/go.mod h1:7RgtFQVsN4MpvQieAJkHSUuvPTiMcEZO57tAnpzlM1I=
github.com/aws/aws-sdk-go-v2/service/healthlake v1.16.0 h1:8CXnXojAdCTtFhrJn2Ez6DDFFykbd9lWOu0Frs1zoqk=
github.com/aws/aws-sdk-go-v2/service/healthlake v1.16.0/go.mod h1:n1IxBDIRdNPVLrEDqwDSZSF60FkFIO43gWVMZo4Y/Rk=
github.com/aws/aws-sdk-go-v2/service/iam v1.19.12 h1:JH1H7POlsZt41X9JYIBLZoXW0Qv+WOuC48xsafsls2Q=
github.com/aws/aws-sdk-go-v2/service/iam v1.19.12/go.mod h1:kAnokExGCYs7zfvZEZdFHvQ/x4ZKIci0Raps6mZI1Ag=
github.com/aws/aws-sdk-go-v2/service/iam v1.20.0 h1:ywXSXkssdnuPlJyCZVO5kAUQhFm/RhsbvWRHklJ0uH4=
github.com/aws/aws-sdk-go-v2/service/iam v1.20.0/go.mod h1:kAnokExGCYs7zfvZEZdFHvQ/x4ZKIci0Raps6mZI1Ag=
github.com/aws/aws-sdk-go-v2/service/identitystore v1.16.11 h1:lXvr+mWzICOdOWQAKGPpAgSuA3lw3XEnzuCUMBVFjgs=
github.com/aws/aws-sdk-go-v2/service/identitystore v1.16.11/go.mod h1:q1wr4mV/OaSB53lfrCL4al7J4ApwOZcy2F8nQ2iTTlw=
github.com/aws/aws-sdk-go-v2/service/inspector2 v1.14.0 h1:NKiE3bgx2O74zQdH6Fs9SRt8QImO3kEPeOVMr1DBzn4=
Expand Down Expand Up @@ -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.29 h1:O1xB5BlSr57lDLgc6v+G+BBRr4HlkQKpapjmkJLCS4c=
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.29/go.mod h1:eBFMtEbjCseWKRv5/M6SONGS0mSbMjxAeVMjCuDLGYE=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.30 h1:if38Z0xWEOR7MzmahrM3gCZDRSlc03Lc2x+hPEdpdnk=
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2 v2.0.0-beta.30/go.mod h1:RcKwhAC0Xu+i2/A7MYVKwhzvGt4KUvonf0IKHyfXYtw=
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=
Expand Down Expand Up @@ -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=
Expand Down
3 changes: 3 additions & 0 deletions internal/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -63,6 +64,7 @@ type Config struct {
MaxRetries int
Profile string
Region string
RetryMode awsv2.RetryMode
S3UsePathStyle bool
SecretKey string
SharedConfigFiles []string
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/fwprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 `AWS_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.",
Expand Down
15 changes: 15 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 `AWS_RETRY_MODE` environment variable.",
},
"s3_use_path_style": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -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))
}
Expand Down
4 changes: 4 additions & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ credential_process = custom-process --username jdoe
|HTTP Proxy|`http_proxy`|`HTTP_PROXY` or `HTTPS_PROXY`|N/A|
|Max Retries|`max_retries`|`AWS_MAX_ATTEMPTS`|`max_attempts`|
|Profile|`profile`|`AWS_PROFILE` or `AWS_DEFAULT_PROFILE`|N/A|
|Retry Mode|`retry_mode`|`AWS_RETRY_MODE`|`retry_mode`|
|Shared Config Files|`shared_config_files`|`AWS_CONFIG_FILE`|N/A|
|Shared Credentials Files|`shared_credentials_files` or `shared_credentials_file`|`AWS_SHARED_CREDENTIALS_FILE`|N/A|
|Use DualStack Endpoints|`use_dualstack_endpoint`|`AWS_USE_DUALSTACK_ENDPOINT`|`use_dualstack_endpoint`|
Expand Down Expand Up @@ -322,6 +323,9 @@ In addition to [generic `provider` arguments](https://www.terraform.io/docs/conf
Can also be set with either the `AWS_REGION` or `AWS_DEFAULT_REGION` environment variables,
or via a shared config file parameter `region` if `profile` is used.
If credentials are retrieved from the EC2 Instance Metadata Service, the region can also be retrieved from the metadata.
* `retry_mode` - (Optional) Specifies how retries are attempted.
Valid values are `standard` and `adaptive`.
Can also be configured using the `AWS_RETRY_MODE` environment variable or the shared config file parameter `retry_mode`.
* `s3_use_path_style` - (Optional) Whether to enable the request to use path-style addressing, i.e., `https://s3.amazonaws.com/BUCKET/KEY`. By default, the S3 client will use virtual hosted bucket addressing, `https://BUCKET.s3.amazonaws.com/KEY`, when possible. Specific to the Amazon S3 service.
* `secret_key` - (Optional) AWS secret key. Can also be set with the `AWS_SECRET_ACCESS_KEY` environment variable, or via a shared configuration and credentials files if `profile` is used. See also `access_key`.
* `shared_config_files` - (Optional) List of paths to AWS shared config files. If not set, the default is `[~/.aws/config]`. A single value can also be set with the `AWS_CONFIG_FILE` environment variable.
Expand Down

0 comments on commit 643a025

Please sign in to comment.