chore(aws): upgrade aws dependencies

This commit is contained in:
2021-11-24 19:10:52 +01:00
parent 165108d1c3
commit b13ff06b36
229 changed files with 13263 additions and 1613 deletions

View File

@ -1,3 +1,19 @@
# v1.8.0 (2021-11-06)
* **Feature**: Updated `github.com/aws/smithy-go` to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.7.0 (2021-10-21)
* **Feature**: Updated to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.6.0 (2021-10-11)
* **Feature**: Respect passed in Context Deadline/Timeout. Updates the IMDS Client operations to not override the passed in Context's Deadline or Timeout options. If an Client operation is called with a Context with a Deadline or Timeout, the client will no longer override it with the client's default timeout.
* **Bug Fix**: Fix IMDS client's response handling and operation timeout race. Fixes #1253
* **Dependency Update**: Updated to the latest SDK module versions
# v1.5.1 (2021-09-17)
* **Dependency Update**: Updated to the latest SDK module versions

View File

@ -1,6 +1,11 @@
// Package imds provides the API client for interacting with the Amazon EC2
// Instance Metadata Service.
//
// All Client operation calls have a default timeout. If the operation is not
// completed before this timeout expires, the operation will be canceled. This
// timeout can be overridden by providing Context with a timeout or deadline
// with calling the client's operations.
//
// See the EC2 IMDS user guide for more information on using the API.
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
package imds

View File

@ -3,4 +3,4 @@
package imds
// goModuleVersion is the tagged release for this module
const goModuleVersion = "1.5.1"
const goModuleVersion = "1.8.0"

View File

@ -1,8 +1,10 @@
package imds
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net/url"
"path"
"time"
@ -52,7 +54,7 @@ func addRequestMiddleware(stack *middleware.Stack,
// Operation timeout
err = stack.Initialize.Add(&operationTimeout{
Timeout: defaultOperationTimeout,
DefaultTimeout: defaultOperationTimeout,
}, middleware.Before)
if err != nil {
return err
@ -142,12 +144,20 @@ func (m *deserializeResponse) HandleDeserialize(
resp, ok := out.RawResponse.(*smithyhttp.Response)
if !ok {
return out, metadata, fmt.Errorf(
"unexpected transport response type, %T", out.RawResponse)
"unexpected transport response type, %T, want %T", out.RawResponse, resp)
}
defer resp.Body.Close()
// Anything thats not 200 |< 300 is error
// read the full body so that any operation timeouts cleanup will not race
// the body being read.
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return out, metadata, fmt.Errorf("read response body failed, %w", err)
}
resp.Body = ioutil.NopCloser(bytes.NewReader(body))
// Anything that's not 200 |< 300 is error
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
resp.Body.Close()
return out, metadata, &smithyhttp.ResponseError{
Response: resp,
Err: fmt.Errorf("request to EC2 IMDS failed"),
@ -213,8 +223,19 @@ const (
defaultOperationTimeout = 5 * time.Second
)
// operationTimeout adds a timeout on the middleware stack if the Context the
// stack was called with does not have a deadline. The next middleware must
// complete before the timeout, or the context will be canceled.
//
// If DefaultTimeout is zero, no default timeout will be used if the Context
// does not have a timeout.
//
// The next middleware must also ensure that any resources that are also
// canceled by the stack's context are completely consumed before returning.
// Otherwise the timeout cleanup will race the resource being consumed
// upstream.
type operationTimeout struct {
Timeout time.Duration
DefaultTimeout time.Duration
}
func (*operationTimeout) ID() string { return "OperationTimeout" }
@ -224,10 +245,11 @@ func (m *operationTimeout) HandleInitialize(
) (
output middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
var cancelFn func()
ctx, cancelFn = context.WithTimeout(ctx, m.Timeout)
defer cancelFn()
if _, ok := ctx.Deadline(); !ok && m.DefaultTimeout != 0 {
var cancelFn func()
ctx, cancelFn = context.WithTimeout(ctx, m.DefaultTimeout)
defer cancelFn()
}
return next.HandleInitialize(ctx, input)
}