awsconfig

package
v0.0.0-...-7139df7 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 4

README

Package cloudeng.io/aws/awsconfig

import cloudeng.io/aws/awsconfig

Package awsconfig provides support for obtaining configuration and associated credentials information for use with AWS.

Functions

Func AccountID
func AccountID(ctx context.Context, cfg aws.Config) (string, error)

AccountID uses the sts service to obtain the calling processes Amazon Account ID (number).

Func ContextWith
func ContextWith(ctx context.Context, cfg *aws.Config) context.Context

ContextWith returns a new context with the aws.Config stored in it.

Func DebugPrintConfig
func DebugPrintConfig(ctx context.Context, out io.Writer, cfg aws.Config) error

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
func FromContext(ctx context.Context) (*aws.Config, bool)

FromContext returns the aws.Config stored in the context.

Func Load
func Load(ctx context.Context, opts ...ConfigOption) (aws.Config, error)

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
func LoadUsingFlags(ctx context.Context, cl AWSFlags) (aws.Config, error)

LoadUsingFlags calls awsconfig.Load with options controlled by the the specified flags.

Func LogAWSConfig
func LogAWSConfig(ctx context.Context, cfg *aws.Config)

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.

Methods
func (c AWSConfig) Load(ctx context.Context) (aws.Config, error)

Load calls awsconfig.Load with options controlled by the config.

func (c AWSConfig) Options(ctx context.Context) ([]ConfigOption, error)

Options returns the ConfigOptions implied by the config. NOTE: it always includes config.WithEC2IMDSRegion so that the region information is retrieved from EC2 IMDS when it's not found by other means.

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 `subcmd:"aws-profile,,aws profile to use for config/authentication" yaml:"aws_profile" doc:"aws profile to use for config/authentication"`
	AWSRegion      string `subcmd:"aws-region,,'aws region to use for API calls, overrides the region set in the profile'" yaml:"aws_region" doc:"aws region to use, overrides the region set in the profile"`
	AWSConfigFiles string `subcmd:"aws-config-files,,comma separated list of config files to use in place of those commonly found in $HOME/.aws" yaml:"aws_config_files,flow" doc:"comma separated list of config files to use in place of those commonly found in $HOME/.aws"`
	AWSKeyInfoID   string `subcmd:"aws-key-info-id,,key info ID to use for authentication" yaml:"aws_key_info_id" doc:"key info ID to use for authentication"`
}

AWSFlags defines commonly used flags that control AWS behaviour.

Methods
func (c AWSFlags) Config() AWSConfig

Config converts the flags to a AWSConfig instance.

Type ConfigOption
type ConfigOption func(o *options)

ConfigOption represents an option to Load.

Functions
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(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(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.

Documentation

Overview

Package awsconfig provides support for obtaining configuration and associated credentials information for use with AWS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountID

func AccountID(ctx context.Context, cfg aws.Config) (string, error)

AccountID uses the sts service to obtain the calling processes Amazon Account ID (number).

func ContextWith

func ContextWith(ctx context.Context, cfg *aws.Config) context.Context

ContextWith returns a new context with the aws.Config stored in it.

func DebugPrintConfig

func DebugPrintConfig(ctx context.Context, out io.Writer, cfg aws.Config) error

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

func FromContext(ctx context.Context) (*aws.Config, bool)

FromContext returns the aws.Config stored in the context.

func Load

func Load(ctx context.Context, opts ...ConfigOption) (aws.Config, error)

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

func LoadUsingFlags(ctx context.Context, cl AWSFlags) (aws.Config, error)

LoadUsingFlags calls awsconfig.Load with options controlled by the the specified flags.

func LogAWSConfig

func LogAWSConfig(ctx context.Context, cfg *aws.Config)

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.

func (AWSConfig) Load

func (c AWSConfig) Load(ctx context.Context) (aws.Config, error)

Load calls awsconfig.Load with options controlled by the config.

func (AWSConfig) Options

func (c AWSConfig) Options(ctx context.Context) ([]ConfigOption, error)

Options returns the ConfigOptions implied by the config. NOTE: it always includes config.WithEC2IMDSRegion so that the region information is retrieved from EC2 IMDS when it's not found by other means.

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.

func (AWSFlags) Config

func (c AWSFlags) Config() AWSConfig

Config converts the flags to a AWSConfig instance.

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.

Jump to

Keyboard shortcuts

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