ec2rolecreds

package
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderName = "EC2RoleProvider"

ProviderName provides a name of EC2Role provider

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	aws.SafeCredentialsProvider
	// contains filtered or unexported fields
}

A Provider retrieves credentials from the EC2 service, and keeps track if those credentials are expired.

The New function must be used to create the Provider.

p := &ec2rolecreds.New(ec2metadata.New(options))

// Expire the credentials 10 minutes before IAM states they should. Proactivily
// refreshing the credentials.
p.ExpiryWindow = 10 * time.Minute

func New added in v0.20.0

func New(client *ec2metadata.Client, options ...func(*ProviderOptions)) *Provider

New returns an initialized Provider value configured to retrieve credentials from EC2 Instance Metadata service.

type ProviderOptions added in v0.20.0

type ProviderOptions 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.
	//
	// So a ExpiryWindow of 10s would cause calls to IsExpired() to return true
	// 10 seconds before the credentials are actually expired.
	//
	// If ExpiryWindow is 0 or less it will be ignored.
	ExpiryWindow time.Duration
}

ProviderOptions is a list of user settable options for setting the behavior of the Provider.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL