ssmconfig

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 9 Imported by: 0

README

ssmconfig

Gets Configuration values from AWS stored SSM and meant to integrate with other config frameworks which may not features which support ssm params.

Example

package main

import (
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/ssm"
	"github.com/bellhops/auth-api/pkg/ssmconfig"
	"github.com/kelseyhightower/envconfig"
)

type Config struct {
	LogLevel        string `envconfig:"LOG_LEVEL"         default:"info"`
	WebPort         string `envconfig:"WEB_PORT"          default:"8000"`
	Environment     string `envconfig:"ENVIRONMENT"       default:"local"`
	StoreLicenseKey string `envconfig:"STORE_LICENSE_KEY" default:"0000000000000000000000000000000000000000" ssmparam:"/store/licensekey"`
}

func main() {
	var config Config
	if err := envconfig.Process("", &config); err != nil {
		panic(err)
	}

	if config.Environment != "local" {
		sess, err := session.NewSession()
		if err != nil {
			panic(err)
		}
		ssmsvc := ssm.New(sess)
		if err := ssmconfig.Process(ssmsvc, "/prefix", &cfg); err != nil {
			panic(err)
		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Process

func Process(ssmsvc ssmiface.SSMAPI, prefix string, spec interface{}) error

Process processes the config struct and any fields with ssmparam tag will be filled. errors if any fields cannot be

Types

This section is empty.

Jump to

Keyboard shortcuts

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