Documentation

Overview

Package aws provides the core SDK's utilities and shared types. Use this package's utilities to simplify setting and reading API operations parameters.

Value and Pointer Conversion Utilities

This package includes a helper conversion utility for each scalar type the SDK's API use. These utilities make getting a pointer of the scalar, and dereferencing a pointer easier.

Each conversion utility comes in two forms. Value to Pointer and Pointer to Value. The Pointer to value will safely dereference the pointer and return its value. If the pointer was nil, the scalar's zero value will be returned.

The value to pointer functions will be named after the scalar type. So get a *string from a string value use the "String" function. This makes it easy to to get pointer of a literal string value, because getting the address of a literal requires assigning the value to a variable first.

var strPtr *string

// Without the SDK's conversion functions
str := "my string"
strPtr = &str

// With the SDK's conversion functions
strPtr = aws.String("my string")

// Convert *string to string value
str = aws.ToString(strPtr)

In addition to scalars the aws package also includes conversion utilities for map and slice for commonly types used in API parameters. The map and slice conversion functions use similar naming pattern as the scalar conversion functions.

var strPtrs []*string
var strs []string = []string{"Go", "Gophers", "Go"}

// Convert []string to []*string
strPtrs = aws.StringSlice(strs)

// Convert []*string to []string
strs = aws.ToStringSlice(strPtrs)

SDK Default HTTP Client

The SDK will use the http.DefaultClient if a HTTP client is not provided to the SDK's Session, or service client constructor. This means that if the http.DefaultClient is modified by other components of your application the modifications will be picked up by the SDK as well.

In some cases this might be intended, but it is a better practice to create a custom HTTP Client to share explicitly through your application. You can configure the SDK to use the custom HTTP Client by setting the HTTPClient value of the SDK's Config type when creating a Session or service client.

Package aws provides core functionality for making requests to AWS services.

Index

Constants

View Source
const SDKName = "aws-sdk-go-v2"

SDKName is the name of this AWS SDK

View Source
const SDKVersion = goModuleVersion

SDKVersion is the version of this SDK

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer value for the bool value passed in.

func BoolMap

func BoolMap(vs map[string]bool) map[string]*bool

BoolMap returns a map of bool pointers from the values passed in.

func BoolSlice

func BoolSlice(vs []bool) []*bool

BoolSlice returns a slice of bool pointers from the values passed in.

func Byte

func Byte(v byte) *byte

Byte returns a pointer value for the byte value passed in.

func ByteMap

func ByteMap(vs map[string]byte) map[string]*byte

ByteMap returns a map of byte pointers from the values passed in.

func ByteSlice

func ByteSlice(vs []byte) []*byte

ByteSlice returns a slice of byte pointers from the values passed in.

func Float32

func Float32(v float32) *float32

Float32 returns a pointer value for the float32 value passed in.

func Float32Map

func Float32Map(vs map[string]float32) map[string]*float32

Float32Map returns a map of float32 pointers from the values passed in.

func Float32Slice

func Float32Slice(vs []float32) []*float32

Float32Slice returns a slice of float32 pointers from the values passed in.

func Float64

func Float64(v float64) *float64

Float64 returns a pointer value for the float64 value passed in.

func Float64Map

func Float64Map(vs map[string]float64) map[string]*float64

Float64Map returns a map of float64 pointers from the values passed in.

func Float64Slice

func Float64Slice(vs []float64) []*float64

Float64Slice returns a slice of float64 pointers from the values passed in.

func Int

func Int(v int) *int

Int returns a pointer value for the int value passed in.

func Int16

func Int16(v int16) *int16

Int16 returns a pointer value for the int16 value passed in.

func Int16Map

func Int16Map(vs map[string]int16) map[string]*int16

Int16Map returns a map of int16 pointers from the values passed in.

func Int16Slice

func Int16Slice(vs []int16) []*int16

Int16Slice returns a slice of int16 pointers from the values passed in.

func Int32

func Int32(v int32) *int32

Int32 returns a pointer value for the int32 value passed in.

func Int32Map

func Int32Map(vs map[string]int32) map[string]*int32

Int32Map returns a map of int32 pointers from the values passed in.

func Int32Slice

func Int32Slice(vs []int32) []*int32

Int32Slice returns a slice of int32 pointers from the values passed in.

func Int64

func Int64(v int64) *int64

Int64 returns a pointer value for the int64 value passed in.

func Int64Map

func Int64Map(vs map[string]int64) map[string]*int64

Int64Map returns a map of int64 pointers from the values passed in.

func Int64Slice

func Int64Slice(vs []int64) []*int64

Int64Slice returns a slice of int64 pointers from the values passed in.

func Int8

func Int8(v int8) *int8

Int8 returns a pointer value for the int8 value passed in.

func Int8Map

func Int8Map(vs map[string]int8) map[string]*int8

Int8Map returns a map of int8 pointers from the values passed in.

func Int8Slice

func Int8Slice(vs []int8) []*int8

Int8Slice returns a slice of int8 pointers from the values passed in.

func IntMap

func IntMap(vs map[string]int) map[string]*int

IntMap returns a map of int pointers from the values passed in.

func IntSlice

func IntSlice(vs []int) []*int

IntSlice returns a slice of int pointers from the values passed in.

func String

func String(v string) *string

String returns a pointer value for the string value passed in.

func StringMap

func StringMap(vs map[string]string) map[string]*string

StringMap returns a map of string pointers from the values passed in.

func StringSlice

func StringSlice(vs []string) []*string

StringSlice returns a slice of string pointers from the values passed in.

func Time

func Time(v time.Time) *time.Time

Time returns a pointer value for the time.Time value passed in.

func TimeMap

func TimeMap(vs map[string]time.Time) map[string]*time.Time

TimeMap returns a map of time.Time pointers from the values passed in.

func TimeSlice

func TimeSlice(vs []time.Time) []*time.Time

TimeSlice returns a slice of time.Time pointers from the values passed in.

func ToBool

func ToBool(p *bool) (v bool)

ToBool returns bool value dereferenced if the passed in pointer was not nil. Returns a bool zero value if the pointer was nil.

func ToBoolMap

func ToBoolMap(vs map[string]*bool) map[string]bool

ToBoolMap returns a map of bool values, that are dereferenced if the passed in pointer was not nil. The bool zero value is used if the pointer was nil.

func ToBoolSlice

func ToBoolSlice(vs []*bool) []bool

ToBoolSlice returns a slice of bool values, that are dereferenced if the passed in pointer was not nil. Returns a bool zero value if the pointer was nil.

func ToByte

func ToByte(p *byte) (v byte)

ToByte returns byte value dereferenced if the passed in pointer was not nil. Returns a byte zero value if the pointer was nil.

func ToByteMap

func ToByteMap(vs map[string]*byte) map[string]byte

ToByteMap returns a map of byte values, that are dereferenced if the passed in pointer was not nil. The byte zero value is used if the pointer was nil.

func ToByteSlice

func ToByteSlice(vs []*byte) []byte

ToByteSlice returns a slice of byte values, that are dereferenced if the passed in pointer was not nil. Returns a byte zero value if the pointer was nil.

func ToFloat32

func ToFloat32(p *float32) (v float32)

ToFloat32 returns float32 value dereferenced if the passed in pointer was not nil. Returns a float32 zero value if the pointer was nil.

func ToFloat32Map

func ToFloat32Map(vs map[string]*float32) map[string]float32

ToFloat32Map returns a map of float32 values, that are dereferenced if the passed in pointer was not nil. The float32 zero value is used if the pointer was nil.

func ToFloat32Slice

func ToFloat32Slice(vs []*float32) []float32

ToFloat32Slice returns a slice of float32 values, that are dereferenced if the passed in pointer was not nil. Returns a float32 zero value if the pointer was nil.

func ToFloat64

func ToFloat64(p *float64) (v float64)

ToFloat64 returns float64 value dereferenced if the passed in pointer was not nil. Returns a float64 zero value if the pointer was nil.

func ToFloat64Map

func ToFloat64Map(vs map[string]*float64) map[string]float64

ToFloat64Map returns a map of float64 values, that are dereferenced if the passed in pointer was not nil. The float64 zero value is used if the pointer was nil.

func ToFloat64Slice

func ToFloat64Slice(vs []*float64) []float64

ToFloat64Slice returns a slice of float64 values, that are dereferenced if the passed in pointer was not nil. Returns a float64 zero value if the pointer was nil.

func ToInt

func ToInt(p *int) (v int)

ToInt returns int value dereferenced if the passed in pointer was not nil. Returns a int zero value if the pointer was nil.

func ToInt16

func ToInt16(p *int16) (v int16)

ToInt16 returns int16 value dereferenced if the passed in pointer was not nil. Returns a int16 zero value if the pointer was nil.

func ToInt16Map

func ToInt16Map(vs map[string]*int16) map[string]int16

ToInt16Map returns a map of int16 values, that are dereferenced if the passed in pointer was not nil. The int16 zero value is used if the pointer was nil.

func ToInt16Slice

func ToInt16Slice(vs []*int16) []int16

ToInt16Slice returns a slice of int16 values, that are dereferenced if the passed in pointer was not nil. Returns a int16 zero value if the pointer was nil.

func ToInt32

func ToInt32(p *int32) (v int32)

ToInt32 returns int32 value dereferenced if the passed in pointer was not nil. Returns a int32 zero value if the pointer was nil.

func ToInt32Map

func ToInt32Map(vs map[string]*int32) map[string]int32

ToInt32Map returns a map of int32 values, that are dereferenced if the passed in pointer was not nil. The int32 zero value is used if the pointer was nil.

func ToInt32Slice

func ToInt32Slice(vs []*int32) []int32

ToInt32Slice returns a slice of int32 values, that are dereferenced if the passed in pointer was not nil. Returns a int32 zero value if the pointer was nil.

func ToInt64

func ToInt64(p *int64) (v int64)

ToInt64 returns int64 value dereferenced if the passed in pointer was not nil. Returns a int64 zero value if the pointer was nil.

func ToInt64Map

func ToInt64Map(vs map[string]*int64) map[string]int64

ToInt64Map returns a map of int64 values, that are dereferenced if the passed in pointer was not nil. The int64 zero value is used if the pointer was nil.

func ToInt64Slice

func ToInt64Slice(vs []*int64) []int64

ToInt64Slice returns a slice of int64 values, that are dereferenced if the passed in pointer was not nil. Returns a int64 zero value if the pointer was nil.

func ToInt8

func ToInt8(p *int8) (v int8)

ToInt8 returns int8 value dereferenced if the passed in pointer was not nil. Returns a int8 zero value if the pointer was nil.

func ToInt8Map

func ToInt8Map(vs map[string]*int8) map[string]int8

ToInt8Map returns a map of int8 values, that are dereferenced if the passed in pointer was not nil. The int8 zero value is used if the pointer was nil.

func ToInt8Slice

func ToInt8Slice(vs []*int8) []int8

ToInt8Slice returns a slice of int8 values, that are dereferenced if the passed in pointer was not nil. Returns a int8 zero value if the pointer was nil.

func ToIntMap

func ToIntMap(vs map[string]*int) map[string]int

ToIntMap returns a map of int values, that are dereferenced if the passed in pointer was not nil. The int zero value is used if the pointer was nil.

func ToIntSlice

func ToIntSlice(vs []*int) []int

ToIntSlice returns a slice of int values, that are dereferenced if the passed in pointer was not nil. Returns a int zero value if the pointer was nil.

func ToString

func ToString(p *string) (v string)

ToString returns string value dereferenced if the passed in pointer was not nil. Returns a string zero value if the pointer was nil.

func ToStringMap

func ToStringMap(vs map[string]*string) map[string]string

ToStringMap returns a map of string values, that are dereferenced if the passed in pointer was not nil. The string zero value is used if the pointer was nil.

func ToStringSlice

func ToStringSlice(vs []*string) []string

ToStringSlice returns a slice of string values, that are dereferenced if the passed in pointer was not nil. Returns a string zero value if the pointer was nil.

func ToTime

func ToTime(p *time.Time) (v time.Time)

ToTime returns time.Time value dereferenced if the passed in pointer was not nil. Returns a time.Time zero value if the pointer was nil.

func ToTimeMap

func ToTimeMap(vs map[string]*time.Time) map[string]time.Time

ToTimeMap returns a map of time.Time values, that are dereferenced if the passed in pointer was not nil. The time.Time zero value is used if the pointer was nil.

func ToTimeSlice

func ToTimeSlice(vs []*time.Time) []time.Time

ToTimeSlice returns a slice of time.Time values, that are dereferenced if the passed in pointer was not nil. Returns a time.Time zero value if the pointer was nil.

func ToUint

func ToUint(p *uint) (v uint)

ToUint returns uint value dereferenced if the passed in pointer was not nil. Returns a uint zero value if the pointer was nil.

func ToUint16

func ToUint16(p *uint16) (v uint16)

ToUint16 returns uint16 value dereferenced if the passed in pointer was not nil. Returns a uint16 zero value if the pointer was nil.

func ToUint16Map

func ToUint16Map(vs map[string]*uint16) map[string]uint16

ToUint16Map returns a map of uint16 values, that are dereferenced if the passed in pointer was not nil. The uint16 zero value is used if the pointer was nil.

func ToUint16Slice

func ToUint16Slice(vs []*uint16) []uint16

ToUint16Slice returns a slice of uint16 values, that are dereferenced if the passed in pointer was not nil. Returns a uint16 zero value if the pointer was nil.

func ToUint32

func ToUint32(p *uint32) (v uint32)

ToUint32 returns uint32 value dereferenced if the passed in pointer was not nil. Returns a uint32 zero value if the pointer was nil.

func ToUint32Map

func ToUint32Map(vs map[string]*uint32) map[string]uint32

ToUint32Map returns a map of uint32 values, that are dereferenced if the passed in pointer was not nil. The uint32 zero value is used if the pointer was nil.

func ToUint32Slice

func ToUint32Slice(vs []*uint32) []uint32

ToUint32Slice returns a slice of uint32 values, that are dereferenced if the passed in pointer was not nil. Returns a uint32 zero value if the pointer was nil.

func ToUint64

func ToUint64(p *uint64) (v uint64)

ToUint64 returns uint64 value dereferenced if the passed in pointer was not nil. Returns a uint64 zero value if the pointer was nil.

func ToUint64Map

func ToUint64Map(vs map[string]*uint64) map[string]uint64

ToUint64Map returns a map of uint64 values, that are dereferenced if the passed in pointer was not nil. The uint64 zero value is used if the pointer was nil.

func ToUint64Slice

func ToUint64Slice(vs []*uint64) []uint64

ToUint64Slice returns a slice of uint64 values, that are dereferenced if the passed in pointer was not nil. Returns a uint64 zero value if the pointer was nil.

func ToUint8

func ToUint8(p *uint8) (v uint8)

ToUint8 returns uint8 value dereferenced if the passed in pointer was not nil. Returns a uint8 zero value if the pointer was nil.

func ToUint8Map

func ToUint8Map(vs map[string]*uint8) map[string]uint8

ToUint8Map returns a map of uint8 values, that are dereferenced if the passed in pointer was not nil. The uint8 zero value is used if the pointer was nil.

func ToUint8Slice

func ToUint8Slice(vs []*uint8) []uint8

ToUint8Slice returns a slice of uint8 values, that are dereferenced if the passed in pointer was not nil. Returns a uint8 zero value if the pointer was nil.

func ToUintMap

func ToUintMap(vs map[string]*uint) map[string]uint

ToUintMap returns a map of uint values, that are dereferenced if the passed in pointer was not nil. The uint zero value is used if the pointer was nil.

func ToUintSlice

func ToUintSlice(vs []*uint) []uint

ToUintSlice returns a slice of uint values, that are dereferenced if the passed in pointer was not nil. Returns a uint zero value if the pointer was nil.

func Uint

func Uint(v uint) *uint

Uint returns a pointer value for the uint value passed in.

func Uint16

func Uint16(v uint16) *uint16

Uint16 returns a pointer value for the uint16 value passed in.

func Uint16Map

func Uint16Map(vs map[string]uint16) map[string]*uint16

Uint16Map returns a map of uint16 pointers from the values passed in.

func Uint16Slice

func Uint16Slice(vs []uint16) []*uint16

Uint16Slice returns a slice of uint16 pointers from the values passed in.

func Uint32

func Uint32(v uint32) *uint32

Uint32 returns a pointer value for the uint32 value passed in.

func Uint32Map

func Uint32Map(vs map[string]uint32) map[string]*uint32

Uint32Map returns a map of uint32 pointers from the values passed in.

func Uint32Slice

func Uint32Slice(vs []uint32) []*uint32

Uint32Slice returns a slice of uint32 pointers from the values passed in.

func Uint64

func Uint64(v uint64) *uint64

Uint64 returns a pointer value for the uint64 value passed in.

func Uint64Map

func Uint64Map(vs map[string]uint64) map[string]*uint64

Uint64Map returns a map of uint64 pointers from the values passed in.

func Uint64Slice

func Uint64Slice(vs []uint64) []*uint64

Uint64Slice returns a slice of uint64 pointers from the values passed in.

func Uint8

func Uint8(v uint8) *uint8

Uint8 returns a pointer value for the uint8 value passed in.

func Uint8Map

func Uint8Map(vs map[string]uint8) map[string]*uint8

Uint8Map returns a map of uint8 pointers from the values passed in.

func Uint8Slice

func Uint8Slice(vs []uint8) []*uint8

Uint8Slice returns a slice of uint8 pointers from the values passed in.

func UintMap

func UintMap(vs map[string]uint) map[string]*uint

UintMap returns a map of uint pointers from the values passed in.

func UintSlice

func UintSlice(vs []uint) []*uint

UintSlice returns a slice of uint pointers from the values passed in.

Types

type AnonymousCredentials

type AnonymousCredentials struct{}

AnonymousCredentials provides a sentinel CredentialsProvider that should be used to instruct the SDK's signing middleware to not sign the request.

Using `nil` credentials when configuring an API client will achieve the same result. The AnonymousCredentials type allows you to configure the SDK's external config loading to not attempt to source credentials from the shared config or environment.

For example you can use this CredentialsProvider with an API client's Options to instruct the client not to sign a request for accessing public S3 bucket objects.

The following example demonstrates using the AnonymousCredentials to prevent SDK's external config loading attempt to resolve credentials.

cfg, err := config.LoadDefaultConfig(context.TODO(),
     config.WithCredentialsProvider(aws.AnonymousCredentials{}),
)
if err != nil {
     log.Fatalf("failed to load config, %v", err)
}

client := s3.NewFromConfig(cfg)

Alternatively you can leave the API client Option's `Credential` member to nil. If using the `NewFromConfig` constructor you'll need to explicitly set the `Credentials` member to nil, if the external config resolved a credential provider.

client := s3.New(s3.Options{
     // Credentials defaults to a nil value.
})

This can also be configured for specific operations calls too.

cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
     log.Fatalf("failed to load config, %v", err)
}

client := s3.NewFromConfig(config)

result, err := client.GetObject(context.TODO(), s3.GetObject{
     Bucket: aws.String("example-bucket"),
     Key: aws.String("example-key"),
}, func(o *s3.Options) {
     o.Credentials = nil
     // Or
     o.Credentials = aws.AnonymousCredentials{}
})

func (AnonymousCredentials) Retrieve

Retrieve implements the CredentialsProvider interface, but will always return error, and cannot be used to sign a request. The AnonymousCredentials type is used as a sentinel type instructing the AWS request signing middleware to not sign a request.

type ClientLogMode

type ClientLogMode uint64

ClientLogMode represents the logging mode of SDK clients. The client logging mode is a bit-field where each bit is a flag that describes the logging behavior for one or more client components. The entire 64-bit group is reserved for later expansion by the SDK.

Example: Setting ClientLogMode to enable logging of retries and requests

clientLogMode := aws.LogRetries | aws.LogRequest

Example: Adding an additional log mode to an existing ClientLogMode value

clientLogMode |= aws.LogResponse
const (
	LogSigning ClientLogMode = 1 << (64 - 1 - iota)
	LogRetries
	LogRequest
	LogRequestWithBody
	LogResponse
	LogResponseWithBody
)

Supported ClientLogMode bits that can be configured to toggle logging of specific SDK events.

func (*ClientLogMode) ClearRequest

func (m *ClientLogMode) ClearRequest()

ClearRequest clears the Request logging mode bit

func (*ClientLogMode) ClearRequestWithBody

func (m *ClientLogMode) ClearRequestWithBody()

ClearRequestWithBody clears the RequestWithBody logging mode bit

func (*ClientLogMode) ClearResponse

func (m *ClientLogMode) ClearResponse()

ClearResponse clears the Response logging mode bit

func (*ClientLogMode) ClearResponseWithBody

func (m *ClientLogMode) ClearResponseWithBody()

ClearResponseWithBody clears the ResponseWithBody logging mode bit

func (*ClientLogMode) ClearRetries

func (m *ClientLogMode) ClearRetries()

ClearRetries clears the Retries logging mode bit

func (*ClientLogMode) ClearSigning

func (m *ClientLogMode) ClearSigning()

ClearSigning clears the Signing logging mode bit

func (ClientLogMode) IsRequest

func (m ClientLogMode) IsRequest() bool

IsRequest returns whether the Request logging mode bit is set

func (ClientLogMode) IsRequestWithBody

func (m ClientLogMode) IsRequestWithBody() bool

IsRequestWithBody returns whether the RequestWithBody logging mode bit is set

func (ClientLogMode) IsResponse

func (m ClientLogMode) IsResponse() bool

IsResponse returns whether the Response logging mode bit is set

func (ClientLogMode) IsResponseWithBody

func (m ClientLogMode) IsResponseWithBody() bool

IsResponseWithBody returns whether the ResponseWithBody logging mode bit is set

func (ClientLogMode) IsRetries

func (m ClientLogMode) IsRetries() bool

IsRetries returns whether the Retries logging mode bit is set

func (ClientLogMode) IsSigning

func (m ClientLogMode) IsSigning() bool

IsSigning returns whether the Signing logging mode bit is set

type Config

type Config struct {
	// The region to send requests to. This parameter is required and must
	// be configured globally or on a per-client basis unless otherwise
	// noted. A full list of regions is found in the "Regions and Endpoints"
	// document.
	//
	// See http://docs.aws.amazon.com/general/latest/gr/rande.html for
	// information on AWS regions.
	Region string

	// The credentials object to use when signing requests. Defaults to a
	// chain of credential providers to search for credentials in environment
	// variables, shared credential file, and EC2 Instance Roles.
	Credentials CredentialsProvider

	// The HTTP Client the SDK's API clients will use to invoke HTTP requests.
	// The SDK defaults to a BuildableClient allowing API clients to create
	// copies of the HTTP Client for service specific customizations.
	//
	// Use a (*http.Client) for custom behavior. Using a custom http.Client
	// will prevent the SDK from modifying the HTTP client.
	HTTPClient HTTPClient

	// An endpoint resolver that can be used to provide or override an endpoint for the given
	// service and region Please see the `aws.EndpointResolver` documentation on usage.
	EndpointResolver EndpointResolver

	// Retryer is a function that provides a Retryer implementation. A Retryer guides how HTTP requests should be
	// retried in case of recoverable failures. When nil the API client will use a default
	// retryer.
	//
	// In general, the provider function should return a new instance of a Retyer if you are attempting
	// to provide a consistent Retryer configuration across all clients. This will ensure that each client will be
	// provided a new instance of the Retryer implementation, and will avoid issues such as sharing the same retry token
	// bucket across services.
	Retryer func() Retryer

	// ConfigSources are the sources that were used to construct the Config.
	// Allows for additional configuration to be loaded by clients.
	ConfigSources []interface{}

	// APIOptions provides the set of middleware mutations modify how the API
	// client requests will be handled. This is useful for adding additional
	// tracing data to a request, or changing behavior of the SDK's client.
	APIOptions []func(*middleware.Stack) error

	// The logger writer interface to write logging messages to. Defaults to
	// standard error.
	Logger logging.Logger

	// Configures the events that will be sent to the configured logger.
	// This can be used to configure the logging of signing, retries, request, and responses
	// of the SDK clients.
	//
	// See the ClientLogMode type documentation for the complete set of logging modes and available
	// configuration.
	ClientLogMode ClientLogMode
}

A Config provides service configuration for service clients.

func NewConfig

func NewConfig() *Config

NewConfig returns a new Config pointer that can be chained with builder methods to set multiple configuration values inline without using pointers.

func (Config) Copy

func (c Config) Copy() Config

Copy will return a shallow copy of the Config object. If any additional configurations are provided they will be merged into the new config returned.

type Credentials

type Credentials struct {
	// AWS Access key ID
	AccessKeyID string

	// AWS Secret Access Key
	SecretAccessKey string

	// AWS Session Token
	SessionToken string

	// Source of the credentials
	Source string

	// Time the credentials will expire.
	CanExpire bool
	Expires   time.Time
}

A Credentials is the AWS credentials value for individual credential fields.

func (Credentials) Expired

func (v Credentials) Expired() bool

Expired returns if the credentials have expired.

func (Credentials) HasKeys

func (v Credentials) HasKeys() bool

HasKeys returns if the credentials keys are set.

type CredentialsCache

type CredentialsCache struct {
	// contains filtered or unexported fields
}

CredentialsCache provides caching and concurrency safe credentials retrieval via the provider's retrieve method.

func NewCredentialsCache

func NewCredentialsCache(provider CredentialsProvider, optFns ...func(options *CredentialsCacheOptions)) *CredentialsCache

NewCredentialsCache returns a CredentialsCache that wraps provider. Provider is expected to not be nil. A variadic list of one or more functions can be provided to modify the CredentialsCache configuration. This allows for configuration of credential expiry window and jitter.

func (*CredentialsCache) Invalidate

func (p *CredentialsCache) Invalidate()

Invalidate will invalidate the cached credentials. The next call to Retrieve will cause the provider's Retrieve method to be called.

func (*CredentialsCache) Retrieve

func (p *CredentialsCache) Retrieve(ctx context.Context) (Credentials, error)

Retrieve returns the credentials. If the credentials have already been retrieved, and not expired the cached credentials will be returned. If the credentials have not been retrieved yet, or expired the provider's Retrieve method will be called.

Returns and error if the provider's retrieve method returns an error.

type CredentialsCacheOptions

type CredentialsCacheOptions struct {

	// ExpiryWindow will allow the credentials to trigger refreshing prior to
	// the credentials actually expiring. This is beneficial so race conditions
	// with expiring credentials do not cause request to fail unexpectedly
	// due to ExpiredTokenException exceptions.
	//
	// An ExpiryWindow of 10s would cause calls to IsExpired() to return true
	// 10 seconds before the credentials are actually expired. This can cause an
	// increased number of requests to refresh the credentials to occur.
	//
	// If ExpiryWindow is 0 or less it will be ignored.
	ExpiryWindow time.Duration

	// ExpiryWindowJitterFrac provides a mechanism for randomizing the expiration of credentials
	// within the configured ExpiryWindow by a random percentage. Valid values are between 0.0 and 1.0.
	//
	// As an example if ExpiryWindow is 60 seconds and ExpiryWindowJitterFrac is 0.5 then credentials will be set to
	// expire between 30 to 60 seconds prior to their actual expiration time.
	//
	// If ExpiryWindow is 0 or less then ExpiryWindowJitterFrac is ignored.
	// If ExpiryWindowJitterFrac is 0 then no randomization will be applied to the window.
	// If ExpiryWindowJitterFrac < 0 the value will be treated as 0.
	// If ExpiryWindowJitterFrac > 1 the value will be treated as 1.
	ExpiryWindowJitterFrac float64
}

CredentialsCacheOptions are the options

type CredentialsProvider

type CredentialsProvider interface {
	// Retrieve returns nil if it successfully retrieved the value.
	// Error is returned if the value were not obtainable, or empty.
	Retrieve(ctx context.Context) (Credentials, error)
}

A CredentialsProvider is the interface for any component which will provide credentials Credentials. A CredentialsProvider is required to manage its own Expired state, and what to be expired means.

A credentials provider implementation can be wrapped with a CredentialCache to cache the credential value retrieved. Without the cache the SDK will attempt to retrieve the credentials for every request.

type CredentialsProviderFunc

type CredentialsProviderFunc func(context.Context) (Credentials, error)

CredentialsProviderFunc provides a helper wrapping a function value to satisfy the CredentialsProvider interface.

func (CredentialsProviderFunc) Retrieve

Retrieve delegates to the function value the CredentialsProviderFunc wraps.

type Endpoint

type Endpoint struct {
	// The base URL endpoint the SDK API clients will use to make API calls to.
	// The SDK will suffix URI path and query elements to this endpoint.
	URL string

	// Specifies if the endpoint's hostname can be modified by the SDK's API
	// client.
	//
	// If the hostname is mutable the SDK API clients may modify any part of
	// the hostname based on the requirements of the API, (e.g. adding, or
	// removing content in the hostname). Such as, Amazon S3 API client
	// prefixing "bucketname" to the hostname, or changing the
	// hostname service name component from "s3." to "s3-accesspoint.dualstack."
	// for the dualstack endpoint of an S3 Accesspoint resource.
	//
	// Care should be taken when providing a custom endpoint for an API. If the
	// endpoint hostname is mutable, and the client cannot modify the endpoint
	// correctly, the operation call will most likely fail, or have undefined
	// behavior.
	//
	// If hostname is immutable, the SDK API clients will not modify the
	// hostname of the URL. This may cause the API client not to function
	// correctly if the API requires the operation specific hostname values
	// to be used by the client.
	//
	// This flag does not modify the API client's behavior if this endpoint
	// will be used instead of Endpoint Discovery, or if the endpoint will be
	// used to perform Endpoint Discovery. That behavior is configured via the
	// API Client's Options.
	HostnameImmutable bool

	// The AWS partition the endpoint belongs to.
	PartitionID string

	// The service name that should be used for signing the requests to the
	// endpoint.
	SigningName string

	// The region that should be used for signing the request to the endpoint.
	SigningRegion string

	// The signing method that should be used for signing the requests to the
	// endpoint.
	SigningMethod string

	// The source of the Endpoint. By default, this will be EndpointSourceServiceMetadata.
	// When providing a custom endpoint, you should set the source as EndpointSourceCustom.
	// If source is not provided when providing a custom endpoint, the SDK may not
	// perform required host mutations correctly. Source should be used along with
	// HostnameImmutable property as per the usage requirement.
	Source EndpointSource
}

Endpoint represents the endpoint a service client should make API operation calls to.

The SDK will automatically resolve these endpoints per API client using an internal endpoint resolvers. If you'd like to provide custom endpoint resolving behavior you can implement the EndpointResolver interface.

type EndpointNotFoundError

type EndpointNotFoundError struct {
	Err error
}

EndpointNotFoundError is a sentinel error to indicate that the EndpointResolver implementation was unable to resolve an endpoint for the given service and region. Resolvers should use this to indicate that an API client should fallback and attempt to use it's internal default resolver to resolve the endpoint.

func (*EndpointNotFoundError) Error

func (e *EndpointNotFoundError) Error() string

Error is the error message.

func (*EndpointNotFoundError) Unwrap

func (e *EndpointNotFoundError) Unwrap() error

Unwrap returns the underlying error.

type EndpointResolver

type EndpointResolver interface {
	ResolveEndpoint(service, region string) (Endpoint, error)
}

EndpointResolver is an endpoint resolver that can be used to provide or override an endpoint for the given service and region. API clients will attempt to use the EndpointResolver first to resolve an endpoint if available. If the EndpointResolver returns an EndpointNotFoundError error, API clients will fallback to attempting to resolve the endpoint using its internal default endpoint resolver.

type EndpointResolverFunc

type EndpointResolverFunc func(service, region string) (Endpoint, error)

EndpointResolverFunc wraps a function to satisfy the EndpointResolver interface.

func (EndpointResolverFunc) ResolveEndpoint

func (e EndpointResolverFunc) ResolveEndpoint(service, region string) (Endpoint, error)

ResolveEndpoint calls the wrapped function and returns the results.

type EndpointSource

type EndpointSource int

EndpointSource is the endpoint source type.

const (
	// EndpointSourceServiceMetadata denotes service modeled endpoint metadata is used as Endpoint Source.
	EndpointSourceServiceMetadata EndpointSource = iota

	// EndpointSourceCustom denotes endpoint is a custom endpoint. This source should be used when
	// user provides a custom endpoint to be used by the SDK.
	EndpointSourceCustom
)

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient provides the interface to provide custom HTTPClients. Generally *http.Client is sufficient for most use cases. The HTTPClient should not follow redirects.

type MissingRegionError

type MissingRegionError struct{}

MissingRegionError is an error that is returned if region configuration value was not found.

func (*MissingRegionError) Error

func (*MissingRegionError) Error() string

type NopRetryer

type NopRetryer struct{}

NopRetryer provides a RequestRetryDecider implementation that will flag all attempt errors as not retryable, with a max attempts of 1.

func (NopRetryer) GetInitialToken

func (NopRetryer) GetInitialToken() func(error) error

GetInitialToken returns a stub function that does nothing.

func (NopRetryer) GetRetryToken

func (NopRetryer) GetRetryToken(context.Context, error) (func(error) error, error)

GetRetryToken returns a stub function that does nothing.

func (NopRetryer) IsErrorRetryable

func (NopRetryer) IsErrorRetryable(error) bool

IsErrorRetryable returns false for all error values.

func (NopRetryer) MaxAttempts

func (NopRetryer) MaxAttempts() int

MaxAttempts always returns 1 for the original request attempt.

func (NopRetryer) RetryDelay

func (NopRetryer) RetryDelay(int, error) (time.Duration, error)

RetryDelay is not valid for the NopRetryer. Will always return error.

type RequestCanceledError

type RequestCanceledError struct {
	Err error
}

RequestCanceledError is the error that will be returned by an API request that was canceled. Requests given a Context may return this error when canceled.

func (*RequestCanceledError) CanceledError

func (*RequestCanceledError) CanceledError() bool

CanceledError returns true to satisfy interfaces checking for canceled errors.

func (*RequestCanceledError) Error

func (e *RequestCanceledError) Error() string

func (*RequestCanceledError) Unwrap

func (e *RequestCanceledError) Unwrap() error

Unwrap returns the underlying error, if there was one.

type Retryer

type Retryer interface {
	// IsErrorRetryable returns if the failed request is retryable. This check
	// should determine if the error can be retried, or if the error is
	// terminal.
	IsErrorRetryable(error) bool

	// MaxAttempts returns the maximum number of attempts that can be made for
	// a request before failing. A value of 0 implies that the request should
	// be retried until it succeeds if the errors are retryable.
	MaxAttempts() int

	// RetryDelay returns the delay that should be used before retrying the
	// request. Will return error if the if the delay could not be determined.
	RetryDelay(attempt int, opErr error) (time.Duration, error)

	// GetRetryToken attempts to deduct the retry cost from the retry token pool.
	// Returning the token release function, or error.
	GetRetryToken(ctx context.Context, opErr error) (releaseToken func(error) error, err error)

	// GetInitalToken returns the initial request token that can increment the
	// retry token pool if the request is successful.
	GetInitialToken() (releaseToken func(error) error)
}

Retryer is an interface to determine if a given error from a request should be retried, and if so what backoff delay to apply. The default implementation used by most services is the retry package's Standard type. Which contains basic retry logic using exponential backoff.

type Ternary

type Ternary int

Ternary is an enum allowing an unknown or none state in addition to a bool's true and false.

const (
	UnknownTernary Ternary = iota
	FalseTernary
	TrueTernary
)

Enumerations for the values of the Ternary type.

func BoolTernary

func BoolTernary(v bool) Ternary

BoolTernary returns a true or false Ternary value for the bool provided.

func (Ternary) Bool

func (t Ternary) Bool() bool

Bool returns true if the value is TrueTernary, false otherwise.

func (Ternary) String

func (t Ternary) String() string

Directories

Path Synopsis
Package arn provides a parser for interacting with Amazon Resource Names.
Package arn provides a parser for interacting with Amazon Resource Names.
protocol
xml
Package retry provides interfaces and implementations for SDK request retry behavior.
Package retry provides interfaces and implementations for SDK request retry behavior.
signer
v4
Package v4 implements signing for AWS V4 signer Provides request signing for request that need to be signed with AWS V4 Signatures.
Package v4 implements signing for AWS V4 signer Provides request signing for request that need to be signed with AWS V4 Signatures.
transport