awsssmenv

package module
v0.0.0-...-34a85da Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2019 License: MIT Imports: 9 Imported by: 0

README

AWS Systems Manager (SSM) Environment Variables

Motivation

Storing configuration in the environment, as in a Twelve factor App, is a common use case. However there are cases where there's the need to properly secure the value of those variables, for example when exposing secrets (such as usernames and passwords) or defining API Tokens.

What is this?

aws-ssm-env is a Go package that allows you load configuration values from environment variables and in cases where explicitly stated it could load the values from AWS SSM.

How does it work?

  1. Define a new struct that will hold all your configuration values, decorate it using the ssm tag.
  2. Load your configuration file, if needed.
  3. Initialize AWS SSM
  4. Load the configuration values.

Please look at the example for a concrete full example.

Development

  • Install direnv
  • Install required tools using ./script/tools.sh
  • go generate ./... and go test ./... as usual

Documentation

Overview

Package awsssmenv allows you to load environment variable and if indicated get remote secure values from AWS SSM.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConfiguration indicates that a configuration is of the wrong type.
	ErrInvalidConfiguration = errors.New("configuration must be a struct pointer")

	// ErrInvalidFieldType indicates that a field is of the wrong type.
	ErrInvalidFieldType = errors.New("field must be a string")

	// ErrInvalidFieldAccess indicates that a field is of the wrong access.
	ErrInvalidFieldAccess = errors.New("field must be exported")
)

Functions

func Get

func Get(ctx context.Context, conf interface{}, svc SSM) error

Get sets field values in the conf struct from environment variables when the fields are decorated with "ssm". If there's another environment variable with the same name postfixed with "_SSM" then that value is used for querying SSM for the remote value.

It supports the "encrypted" option to indicate if the value should be retrieved from AWS SSM using encryption.

Types

type SSM

type SSM interface {
	GetParameterWithContext(aws.Context, *ssm.GetParameterInput, ...request.Option) (*ssm.GetParameterOutput, error)
}

SSM defines the type implementing the SSM call. This type should define the exact method defined in github.com/aws/aws-sdk-go/service/ssm so the real AWS SSM can be used.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
Run it as: AWS_REGION=us-east1 go run examples/main.go
Run it as: AWS_REGION=us-east1 go run examples/main.go

Jump to

Keyboard shortcuts

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