ssmvars

package module
v0.0.0-...-fc6dc9f Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2018 License: MIT Imports: 10 Imported by: 4

README

ssmvars

Godoc CircleCI Go Report Card codecov

Utility library to store app configuration secrets using AWS SSM Parameter Store backend.

The concept behind this library is that the VariableRepository takes "exclusive ownership" of a variable prefix, and then allows setting up multiple namespaces as well as individual variables in them.

Resulting variables thus constructed like this in Parameter Store:

/${prefix}/variables/${namespace}/${variable}

There are two types of variables - plain (read-write) and secret (write-only). The latter type is implemented using SecureString - to manage those, you will need to provide a valid KMS key ID for the library to use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Environment

func Environment(ctx context.Context, reader Reader, namespace string) ([]string, error)

Environment is a convenience function presenting the content of a Reader in a way that's compatible with operations that expect os.Environment.

Types

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

ReadWriter is a 'read-write' proxy to variables stored in SSM.

func New

func New(client ssmiface.SSMAPI, prefix, kmsKeyID string) ReadWriter

New returns a Variables ReadWriter backed by SSM Parameter Store.

type Reader

type Reader interface {
	// ShowVariable retrieves an individual variable by its name.
	ShowVariable(ctx context.Context, namespace, name string) (*Variable, error)

	// ListVariables lists all variables for a given namespace. It does
	// pagination automatically, with 10 entries per page. In pathological
	// cases, this operation could take a while.
	ListVariables(ctx context.Context, namespace string) ([]*Variable, error)
}

Reader provides are 'read-only' proxy to variables stored in SSM.

func NewReader

func NewReader(client ssmiface.SSMAPI, prefix string) Reader

NewReader returns a Variables Reader backed by SSM Parameter Store.

type Variable

type Variable struct {
	// Name of the variable.
	Name string

	// Value of the variable.
	Value string

	// Whether the variable should be readable from the UI.
	WriteOnly bool
}

Variable represents a single configuration variable.

type Writer

type Writer interface {
	// CreateVariable creates or updates an existing variable.
	CreateVariable(ctx context.Context, namespace string, variable *Variable) (*Variable, error)

	// DeleteVariable deletes an existing variable.
	DeleteVariable(ctx context.Context, namespace, name string) (*Variable, error)

	// Reset removes all variables for a given namespace.
	Reset(ctx context.Context, namespace string) error
}

Writer provides are 'write-only' proxy to variables stored in SSM.

func NewWriter

func NewWriter(client ssmiface.SSMAPI, prefix, kmsKeyID string) Writer

NewWriter returns a Variables Writer backed by SSM Parameter Store.

Jump to

Keyboard shortcuts

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