Documentation
¶
Overview ¶
Package awsconfig provides support for obtaining configuration and associated credentials information for use with AWS.
Index ¶
- func AccountID(ctx context.Context, cfg aws.Config) (string, error)
- func ContextWith(ctx context.Context, cfg *aws.Config) context.Context
- func DebugPrintConfig(ctx context.Context, out io.Writer, cfg aws.Config) error
- func FromContext(ctx context.Context) (*aws.Config, bool)
- func Load(ctx context.Context, opts ...ConfigOption) (aws.Config, error)
- func LoadUsingFlags(ctx context.Context, cl AWSFlags) (aws.Config, error)
- func LogAWSConfig(ctx context.Context, cfg *aws.Config)
- func NewKeyInfo(id, user string, token []byte, extra KeyInfoExtra) keys.Info
- type AWSConfig
- type AWSFlags
- type ConfigOption
- type KeyInfoExtra
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountID ¶
AccountID uses the sts service to obtain the calling processes Amazon Account ID (number).
func ContextWith ¶
ContextWith returns a new context with the aws.Config stored in it.
func DebugPrintConfig ¶
DebugPrintConfig dumps the aws.Config to help with debugging configuration issues. It displays the types of the fields that can't be directly printed.
func FromContext ¶
FromContext returns the aws.Config stored in the context.
func Load ¶
Load attempts to load configuration information from multiple sources, including the current process' environment, shared configuration files (by default $HOME/.aws) and also from ec2 instance metadata (currently for the AWS region).
func LoadUsingFlags ¶
LoadUsingFlags calls awsconfig.Load with options controlled by the the specified flags.
func LogAWSConfig ¶
LogAWSConfig logs the aws.Config to the slog.Logger in the context.
func NewKeyInfo ¶
func NewKeyInfo(id, user string, token []byte, extra KeyInfoExtra) keys.Info
NewKeyInfo creates a new keys.Info appropriate for use with static credentials for AWS.
Types ¶
type AWSConfig ¶
type AWSConfig struct {
AWS bool `yaml:"aws"`
AWSProfile string `yaml:"aws_profile"`
AWSRegion string `yaml:"aws_region"`
AWSConfigFiles []string `yaml:"aws_config_files"`
AWSKeyInfoID string `yaml:"aws_key_info_id"`
}
AWSConfig represents a minimal AWS configuration required to authenticate and interact with AWS services.
type AWSFlags ¶
type AWSFlags struct {
AWS bool `subcmd:"aws,false,set to enable AWS functionality" yaml:"aws" doc:"set to true enable AWS functionality"`
AWSProfile string `` /* 136-byte string literal not displayed */
AWSRegion string `` /* 178-byte string literal not displayed */
AWSConfigFiles string `` /* 243-byte string literal not displayed */
AWSKeyInfoID string `` /* 130-byte string literal not displayed */
}
AWSFlags defines commonly used flags that control AWS behaviour.
type ConfigOption ¶
type ConfigOption func(o *options)
ConfigOption represents an option to Load.
func ConfigOptionsFromFlags ¶
func ConfigOptionsFromFlags(ctx context.Context, cl AWSFlags) ([]ConfigOption, error)
ConfigOptionsFromFlags returns the ConfigOptions implied by the flags. NOTE: it always includes config.WithEC2IMDSRegion so that the region information is retrieved from EC2 IMDS when it's not found by other means.
func ConfigOptionsFromKeyInfo ¶
func ConfigOptionsFromKeyInfo(keyInfo keys.Info) ([]ConfigOption, error)
ConfigOptionsFromKeyInfo returns the ConfigOptions implied by the key info. Note that it will textutil.TrimUnicodeQuotes on the AccessKeyID and token value to remove any leading/trailing unicode quotes.
func WithConfigOptions ¶
func WithConfigOptions(fn ...func(*config.LoadOptions) error) ConfigOption
WithConfigOptions will pass the supplied options from the aws config package.
type KeyInfoExtra ¶
type KeyInfoExtra struct {
AccessKeyID string `yaml:"access_key_id"`
Region string `yaml:"region"`
}
KeyInfoExtra is the extra information stored in a key info for AWS. It is used to populate the AWS config with the access key ID and region. The SecretAccessKey is stored in the token field of the key info.