AWS SDK for Go (PILOT)
API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see https://docs.aws.amazon.com/sdk-for-go/api/.

We welcome your feedback on this new version of the documentation. Send your comments to aws-sdkdocs-feedback@amazon.com.

Expiry

import "github.com/aws/aws-sdk-go/aws/credentials"

type Expiry struct { CurrentTime func() time.Time }

A Expiry provides shared expiration logic to be used by credentials providers to implement expiry functionality.

The best method to use this struct is as an anonymous field within the provider's struct.

Example:

type EC2RoleProvider struct { Expiry ... }

CurrentTime

Type: func() time.Time

If set will be used by IsExpired to determine the current time. Defaults to time.Now if CurrentTime is not set. Available for testing to be able to mock out the current time.

Method

ExpiresAt

func (e *Expiry) ExpiresAt() time.Time

ExpiresAt returns the expiration time of the credential

IsExpired

func (e *Expiry) IsExpired() bool

IsExpired returns if the credentials are expired.

SetExpiration

func (e *Expiry) SetExpiration(expiration time.Time, window time.Duration)

SetExpiration sets the expiration IsExpired will check when called.

If window is greater than 0 the expiration time will be reduced by the window value.

Using a window is helpful to trigger credentials to expire sooner than the expiration time given to ensure no requests are made with expired tokens.

On this page: