qsaws

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvAccessKey = "AWS_ACCESS_KEY_ID"
	EnvSecretKey = "AWS_SECRET_KEY"
	EnvRegion    = "AWS_REGION"
)

Variables

View Source
var (
	ErrNoAwsAccessKey     = errors.New("no AWS access key found")
	ErrNoAwsSecretKey     = errors.New("no AWS secret key found")
	ErrNoAwsRegion        = errors.New("no AWS region found")
	ErrMissingCredentials = errors.New("no AWS credentials found")
)
View Source
var Module = fx.Options(
	fx.Provide(
		fx.Annotate(
			func(cfg *aws.Config, lc fx.Lifecycle) (*session.Session, error) {
				s, err := newSession(cfg)
				if err != nil {
					return nil, err
				}
				return s, nil
			},
		),
	),
)

Functions

func ProvideAwsConfig

func ProvideAwsConfig(typ qsconfig.ConfigType[*aws.Config]) fx.Option

Validate, then provide the app with a AWS config.

To use this:

var Module = fx.Options(
	qsaws.ProvideAwsConfig(&qsaws.EnvConfigType{})
)

this code will provide a new default instance of a aws.Config that can be used to instantiate a aws.Session.

in case you want to customize a aws.Config yourself, implements:

qsconfig.ConfigType[*aws.Config]

If you need custom dependencies, don't use this, instead, create a fx.Option yourself:

 fx.Provide(func (dep *Dependencies) (*aws.Config, error) {
		// Do something
		return &aws.Config{
			// Options here
		}
 })

func ValidateConfig

func ValidateConfig(cfg *aws.Config) error

Validate a set of AWS config for error

Types

type EnvConfigType

type EnvConfigType struct{}

Requires these following environment variables

  • AWS_ACCESS_KEY_ID: The access key ID
  • AWS_SECRET_KEY: The secret key
  • AWS_REGION: The AWS region

func (*EnvConfigType) Config

func (t *EnvConfigType) Config() (*aws.Config, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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