config

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// ProfileEnvVar is the profile environment variable name
	ProfileEnvVar = "AWS_PROFILE"
	// DefaultProfileEnvVar is the default profile environment variable name
	DefaultProfileEnvVar = "AWS_DEFAULT_PROFILE"
)
View Source
const ConfigFileEnvVar = "AWS_CONFIG_FILE"

ConfigFileEnvVar is the configuration file environment variable name

View Source
const CredentialsFileEnvVar = "AWS_SHARED_CREDENTIALS_FILE"

CredentialsFileEnvVar is the credentials file environment variable name

Variables

View Source
var DefaultProfileName = strings.ToLower(ini.DefaultSection)

DefaultProfileName is the name of the default section in the config file

Functions

func NewAwsConfigResolver added in v0.3.0

func NewAwsConfigResolver(source interface{}) (*awsConfigResolver, error)

NewAwsConfigResolver creates a default AWS config resolver which will lookup information in the INI config source for the default profile, and source_profile (if configured), and merge with the data in the provided profile

func ResolveProfile added in v0.2.4

func ResolveProfile(p *string) string

ResolveProfile is a helper method to check the env vars for a profile name if the provided argument is nil or empty

Types

type AwsConfig added in v0.3.0

type AwsConfig struct {
	CaBundle         string `ini:"ca_bundle" env:"AWS_CA_BUNDLE"`
	CredentialSource string `ini:"credential_source"`
	DurationSeconds  int    `ini:"duration_seconds" env:"DURATION_SECONDS,CREDENTIALS_DURATION"`
	ExternalId       string `ini:"external_id" env:"EXTERNAL_ID"`
	MfaSerial        string `ini:"mfa_serial" env:"MFA_SERIAL"`
	Profile          string `env:"AWS_PROFILE"`
	Region           string `ini:"region" env:"AWS_REGION,AWS_DEFAULT_REGION"`
	RoleArn          string `ini:"role_arn"`
	RoleSessionName  string `ini:"role_session_name" env:"AWS_ROLE_SESSION_NAME"`
	SourceProfile    string `ini:"source_profile"`
	// contains filtered or unexported fields
}

AwsConfig is the type containing the explicitly supported AWS SDK configuration attributes

func (*AwsConfig) Get added in v0.3.0

func (c *AwsConfig) Get(attr string) string

Get will return the value of the INI config attribute name specified in attr Useful for retrieving custom attributes in the config, or seeing the attribute's raw data

type AwsConfigProvider added in v0.3.0

type AwsConfigProvider interface {
	Config(profile ...string) (*AwsConfig, error)
	ListProfiles(bool) []string
}

AwsConfigProvider is an interface defining the contract for conforming types to provide AWS configuration

type AwsConfigResolver added in v0.3.0

type AwsConfigResolver interface {
	Merge(config ...*AwsConfig) (*AwsConfig, error)
	Resolve(profile ...string) (*AwsConfig, error)
	ListProfiles(bool) []string
}

AwsConfigResolver is an interface defining the contract for conforming types to provide AWS config resolution

type AwsCredentialProvider added in v0.3.0

type AwsCredentialProvider interface {
	Credentials(profile ...string) (credentials.Value, error)
}

AwsCredentialProvider is an interface defining the contract for conforming types to provide AWS credentials

type EnvConfigProvider added in v0.3.0

type EnvConfigProvider uint8

EnvConfigProvider enables the lookup of AWS configuration from environment variables

func NewEnvConfigProvider added in v0.3.0

func NewEnvConfigProvider() *EnvConfigProvider

NewEnvConfigProvider creates an EnvConfigProvider with the default configuration

func (*EnvConfigProvider) Config added in v0.3.0

func (p *EnvConfigProvider) Config(profile ...string) (*AwsConfig, error)

Config will return the configuration attributes found in the environment variables. The profile argument to this call is ignored, and only used to set the Profile attribute of the returned AwsConfig object.

func (*EnvConfigProvider) ListProfiles added in v0.3.1

func (p *EnvConfigProvider) ListProfiles(roles bool) []string

ListProfiles is not supported for EnvConfigProviders, returns an empty array

type EnvCredentialProvider added in v0.3.0

type EnvCredentialProvider uint8

EnvCredentialProvider enables the lookup of AWS credentials from environment variables

func NewEnvCredentialProvider added in v0.3.0

func NewEnvCredentialProvider() *EnvCredentialProvider

NewEnvCredentialProvider initializes a default EnvCredentialProvider

func (*EnvCredentialProvider) Credentials added in v0.3.0

func (p *EnvCredentialProvider) Credentials(profile ...string) (credentials.Value, error)

Credentials will retrieve AWS credentials from the SDK supported environment variables. For Access Keys, these are ... AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY for Secret Keys, these are ... AWS_SECRET_ACCESS_KEY and AWS_SECRET_KEY for Session Tokens, this is ... AWS_SESSION_TOKEN

type IniConfigProvider added in v0.3.0

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

IniConfigProvider enables the lookup of AWS configuration from an ini-formatted data source

func NewIniConfigProvider added in v0.3.0

func NewIniConfigProvider(source interface{}) (*IniConfigProvider, error)

NewIniConfigProvider initializes a default IniConfigProvider using the specified source. Valid sources include, a string representing a file path or url (file and http(s) urls supported), a Golang *url.URL, an []byte, a *os.File, or an io.Reader

func (IniConfigProvider) Close added in v0.3.0

func (f IniConfigProvider) Close() error

func (*IniConfigProvider) Config added in v0.3.0

func (p *IniConfigProvider) Config(profile ...string) (*AwsConfig, error)

Config will return the configuration attributes for the specified profile. If the profile is nil, the configuration of the default profile will be returned.

func (*IniConfigProvider) ListProfiles added in v0.3.1

func (p *IniConfigProvider) ListProfiles(roles bool) []string

ListProfiles will return an array of profile names found in the config file. If the roles arg is false, then all profile sections found in the config file will be returned; otherwise only profile sections which have the role_arn property will be returned.

func (*IniConfigProvider) Profile added in v0.3.0

func (p *IniConfigProvider) Profile(profile string) (*ini.Section, error)

Profile overrides the default Profile lookup logic to include a callback to re-try the lookup with "profile " prepended to the name

func (IniConfigProvider) ProfileStrings added in v0.3.0

func (f IniConfigProvider) ProfileStrings() []string

type IniCredentialProvider added in v0.3.0

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

IniCredentialProvider enables the lookup of AWS credentials from an ini-formatted data source

func NewIniCredentialProvider added in v0.3.0

func NewIniCredentialProvider(source interface{}) (*IniCredentialProvider, error)

NewIniCredentialProvider initializes a default IniCredentialProvider using the specified source. Valid sources include, a string representing a file path or url (file and http(s) urls supported), a Golang *url.URL, an []byte, a *os.File, or an io.Reader

func (IniCredentialProvider) Close added in v0.3.0

func (f IniCredentialProvider) Close() error

func (*IniCredentialProvider) Credentials added in v0.3.0

func (p *IniCredentialProvider) Credentials(profile ...string) (credentials.Value, error)

Credentials will retrieve AWS credentials from the configured source location, for the provided profile. If the profile argument is nil or empty, the value of the AWS_PROFILE environment variable will be used, and if that isn't set, return credentials set in the "default" profile

func (IniCredentialProvider) Profile added in v0.3.0

func (f IniCredentialProvider) Profile(name string) (*ini.Section, error)

Default profile resolution method. Returns an error if the section is not found in the config file. Since there is no explicit format of the profile data (the cli/sdk defines some values, but allows custom attributes), the returned value is the ini file section data, where the caller will be able to process the profile attributes locally.

func (IniCredentialProvider) ProfileStrings added in v0.3.0

func (f IniCredentialProvider) ProfileStrings() []string

func (*IniCredentialProvider) UpdateCredentials added in v0.3.0

func (p *IniCredentialProvider) UpdateCredentials(profile string, creds interface{}) error

UpdateCredentials updates the given profile with the provided credentials. The creds can be an iam.AccessKey or credentials.Value type (or pointers to either). Updates are only made to the in-memory representation of the data, it is the caller's responsibility to persist the information to storage, either via the SaveTo() or WriteTo() methods.

Jump to

Keyboard shortcuts

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