diff --git a/go.mod b/go.mod index ca835282..601582ba 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.42.39 - github.com/hashicorp/aws-sdk-go-base v0.7.1 + github.com/hashicorp/aws-sdk-go-base v1.0.0 github.com/hashicorp/terraform-plugin-docs v0.5.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 ) diff --git a/go.sum b/go.sum index 5beebe9b..0ced365e 100644 --- a/go.sum +++ b/go.sum @@ -167,8 +167,8 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/hashicorp/aws-sdk-go-base v0.7.1 h1:7s/aR3hFn74tYPVihzDyZe7y/+BorN70rr9ZvpV3j3o= -github.com/hashicorp/aws-sdk-go-base v0.7.1/go.mod h1:2fRjWDv3jJBeN6mVWFHV6hFTNeFBx2gpDLQaZNxUVAY= +github.com/hashicorp/aws-sdk-go-base v1.0.0 h1:J7MMLOfSoDWkusy+cSzKYG1/aFyCzYJmdE0mod3/WLw= +github.com/hashicorp/aws-sdk-go-base v1.0.0/go.mod h1:2fRjWDv3jJBeN6mVWFHV6hFTNeFBx2gpDLQaZNxUVAY= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= diff --git a/vendor/github.com/hashicorp/aws-sdk-go-base/.golangci.yml b/vendor/github.com/hashicorp/aws-sdk-go-base/.golangci.yml index 687b0c78..3662c9a4 100644 --- a/vendor/github.com/hashicorp/aws-sdk-go-base/.golangci.yml +++ b/vendor/github.com/hashicorp/aws-sdk-go-base/.golangci.yml @@ -8,14 +8,14 @@ linters: - deadcode - dogsled - errcheck + - errname + - exportloopref - goconst - gofmt - gomnd - gosimple - ineffassign - - interfacer - misspell - - scopelint - staticcheck - structcheck - unconvert diff --git a/vendor/github.com/hashicorp/aws-sdk-go-base/CHANGELOG.md b/vendor/github.com/hashicorp/aws-sdk-go-base/CHANGELOG.md index 86605ff7..1bf9bc20 100644 --- a/vendor/github.com/hashicorp/aws-sdk-go-base/CHANGELOG.md +++ b/vendor/github.com/hashicorp/aws-sdk-go-base/CHANGELOG.md @@ -1,3 +1,13 @@ +# v1.1.0 (Unreleased) + +# v1.0.0 (September 28, 2021) + +ENHANCEMENTS + +* Support HTTP proxy configuration. #46 +* Enables verbose credential chain errors. #63 +* Extends `tfawserr.ErrCodeEquals` to chech multiple error codes. #55 + # v0.7.1 (April 14, 2021) BUG FIXES diff --git a/vendor/github.com/hashicorp/aws-sdk-go-base/GNUmakefile b/vendor/github.com/hashicorp/aws-sdk-go-base/GNUmakefile index 3001f2ee..4236e269 100644 --- a/vendor/github.com/hashicorp/aws-sdk-go-base/GNUmakefile +++ b/vendor/github.com/hashicorp/aws-sdk-go-base/GNUmakefile @@ -4,14 +4,19 @@ fmt: @echo "==> Fixing source code with gofmt..." gofmt -s -w ./ -lint: - @echo "==> Checking source code against linters..." +lint: golangci-lint importlint + +golangci-lint: @golangci-lint run ./... +importlint: + @impi --local . --scheme stdThirdPartyLocal ./... + test: go test -timeout=30s -parallel=4 ./... tools: - GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint + cd tools && go install github.com/golangci/golangci-lint/cmd/golangci-lint + cd tools && go install github.com/pavius/impi/cmd/impi .PHONY: lint test tools diff --git a/vendor/github.com/hashicorp/aws-sdk-go-base/awsauth.go b/vendor/github.com/hashicorp/aws-sdk-go-base/awsauth.go index 54aba310..d3fab03a 100644 --- a/vendor/github.com/hashicorp/aws-sdk-go-base/awsauth.go +++ b/vendor/github.com/hashicorp/aws-sdk-go-base/awsauth.go @@ -174,9 +174,10 @@ func GetCredentialsFromSession(c *Config) (*awsCredentials.Credentials, error) { // client from automatically lowering the timeout to 1 second. options := &session.Options{ Config: aws.Config{ - EndpointResolver: c.EndpointResolver(), - MaxRetries: aws.Int(0), - Region: aws.String(c.Region), + CredentialsChainVerboseErrors: aws.Bool(true), + EndpointResolver: c.EndpointResolver(), + MaxRetries: aws.Int(0), + Region: aws.String(c.Region), }, Profile: c.Profile, SharedConfigState: session.SharedConfigEnable, @@ -253,11 +254,12 @@ func GetCredentials(c *Config) (*awsCredentials.Credentials, error) { c.AssumeRoleARN, c.AssumeRoleSessionName, c.AssumeRoleExternalID) awsConfig := &aws.Config{ - Credentials: creds, - EndpointResolver: c.EndpointResolver(), - Region: aws.String(c.Region), - MaxRetries: aws.Int(c.MaxRetries), - HTTPClient: cleanhttp.DefaultClient(), + CredentialsChainVerboseErrors: aws.Bool(true), + Credentials: creds, + EndpointResolver: c.EndpointResolver(), + Region: aws.String(c.Region), + MaxRetries: aws.Int(c.MaxRetries), + HTTPClient: cleanhttp.DefaultClient(), } if c.DebugLogging { diff --git a/vendor/github.com/hashicorp/aws-sdk-go-base/config.go b/vendor/github.com/hashicorp/aws-sdk-go-base/config.go index c5f9daaf..74ff0f61 100644 --- a/vendor/github.com/hashicorp/aws-sdk-go-base/config.go +++ b/vendor/github.com/hashicorp/aws-sdk-go-base/config.go @@ -16,6 +16,7 @@ type Config struct { DebugLogging bool IamEndpoint string Insecure bool + HTTPProxy string MaxRetries int Profile string Region string diff --git a/vendor/github.com/hashicorp/aws-sdk-go-base/session.go b/vendor/github.com/hashicorp/aws-sdk-go-base/session.go index 8271b365..078cc3f2 100644 --- a/vendor/github.com/hashicorp/aws-sdk-go-base/session.go +++ b/vendor/github.com/hashicorp/aws-sdk-go-base/session.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net/http" + "net/url" "os" "github.com/aws/aws-sdk-go/aws" @@ -37,10 +38,11 @@ const ( func GetSessionOptions(c *Config) (*session.Options, error) { options := &session.Options{ Config: aws.Config{ - EndpointResolver: c.EndpointResolver(), - HTTPClient: cleanhttp.DefaultClient(), - MaxRetries: aws.Int(0), - Region: aws.String(c.Region), + CredentialsChainVerboseErrors: aws.Bool(true), + EndpointResolver: c.EndpointResolver(), + HTTPClient: cleanhttp.DefaultClient(), + MaxRetries: aws.Int(0), + Region: aws.String(c.Region), }, Profile: c.Profile, SharedConfigState: session.SharedConfigEnable, @@ -55,13 +57,22 @@ func GetSessionOptions(c *Config) (*session.Options, error) { // add the validated credentials to the session options options.Config.Credentials = creds + transport := options.Config.HTTPClient.Transport.(*http.Transport) if c.Insecure { - transport := options.Config.HTTPClient.Transport.(*http.Transport) transport.TLSClientConfig = &tls.Config{ InsecureSkipVerify: true, } } + if c.HTTPProxy != "" { + proxyUrl, err := url.Parse(c.HTTPProxy) + if err != nil { + return nil, fmt.Errorf("error parsing HTTP proxy URL: %w", err) + } + + transport.Proxy = http.ProxyURL(proxyUrl) + } + if c.DebugLogging { options.Config.LogLevel = aws.LogLevel(aws.LogDebugWithHTTPBody | aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors) options.Config.Logger = DebugLogger{} @@ -126,13 +137,13 @@ func GetSession(c *Config) (*session.Session, error) { } // RequestError: send request failed // caused by: Post https://FQDN/: dial tcp: lookup FQDN: no such host - if tfawserr.ErrMessageAndOrigErrContain(r.Error, "RequestError", "send request failed", "no such host") { + if tfawserr.ErrMessageAndOrigErrContain(r.Error, request.ErrCodeRequestError, "send request failed", "no such host") { log.Printf("[WARN] Disabling retries after next request due to networking issue") r.Retryable = aws.Bool(false) } // RequestError: send request failed // caused by: Post https://FQDN/: dial tcp IPADDRESS:443: connect: connection refused - if tfawserr.ErrMessageAndOrigErrContain(r.Error, "RequestError", "send request failed", "connection refused") { + if tfawserr.ErrMessageAndOrigErrContain(r.Error, request.ErrCodeRequestError, "send request failed", "connection refused") { log.Printf("[WARN] Disabling retries after next request due to networking issue") r.Retryable = aws.Bool(false) } diff --git a/vendor/github.com/hashicorp/aws-sdk-go-base/tfawserr/awserr.go b/vendor/github.com/hashicorp/aws-sdk-go-base/tfawserr/awserr.go index 20af6060..1c725673 100644 --- a/vendor/github.com/hashicorp/aws-sdk-go-base/tfawserr/awserr.go +++ b/vendor/github.com/hashicorp/aws-sdk-go-base/tfawserr/awserr.go @@ -31,11 +31,15 @@ func ErrMessageAndOrigErrContain(err error, code string, message string, origErr // ErrCodeEquals returns true if the error matches all these conditions: // * err is of type awserr.Error -// * Error.Code() equals code -func ErrCodeEquals(err error, code string) bool { +// * Error.Code() equals one of the passed codes +func ErrCodeEquals(err error, codes ...string) bool { var awsErr awserr.Error if errors.As(err, &awsErr) { - return awsErr.Code() == code + for _, code := range codes { + if awsErr.Code() == code { + return true + } + } } return false } diff --git a/vendor/modules.txt b/vendor/modules.txt index 8b8a1518..85fe08a2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -104,7 +104,7 @@ github.com/google/go-cmp/cmp/internal/value github.com/google/uuid # github.com/googleapis/gax-go/v2 v2.0.5 github.com/googleapis/gax-go/v2 -# github.com/hashicorp/aws-sdk-go-base v0.7.1 +# github.com/hashicorp/aws-sdk-go-base v1.0.0 ## explicit github.com/hashicorp/aws-sdk-go-base github.com/hashicorp/aws-sdk-go-base/tfawserr