springload/ssm-parent

Name: ssm-parent

Owner: Springload

Description: Docker entrypoint that gets parameters from AWS SSM Parameter Store

Created: 2018-04-16 22:55:38.0

Updated: 2018-05-04 08:29:17.0

Pushed: 2018-04-17 03:11:31.0

Homepage:

Size: 15

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

SSM Parent

This is a parent process for Docker with one addition: it can read from AWS SSM Parameter store.

The way it works is that ssm-parent can be used as an entrypoint for Docker. Firstly, it retrieves all specified parameters, then injects them to the environment, and finally runs the command.

All parameters must be in JSON format, i.e.:

{
    "ENVIRONMENT": "production"
}

If a few parameters are specified, all JSON entities will be read and merged into one, overriding existing keys, i.e.

Parameter one:

{
    "USERNAME": "myuser",
    "DATABASE": "production"
}

Parameter two:

{
    "DATABASE": "test"
}

The result will be merged as this:

{
    "USERNAME": "myuser",
    "DATABASE": "test"
}
How to use

That should be pretty self-explanatory.

-parent help                                                                                                         <aws:hosting>
Parent is a docker entrypoint.

ets specified parameters (possibly secret) from AWS SSM Parameter Store,
 exports them to the underlying process.

e:
m-parent [command]

lable Commands:
lp        Help about any command
int       Prints the specified parameters.
n         Runs the specified command

s:
, --help               help for ssm-parent
, --name stringArray   Name of the SSM parameter to retrieve. Can be specified multiple times.
, --path stringArray   Path to a SSM parameter. Can be specified multiple times.
, --recursive          Walk through the provided SSM paths recursively.
, --strict             Strict mode. Fail if found less parameters than number of names.

"ssm-parent [command] --help" for more information about a command.

The command ssm-parent print can be used to check the result.

Example Dockerfile part
PROJECT myproject
ENVIRONMENT production

wget -O /tmp/ssm-parent.tar.gz https://github.com/springload/ssm-parent/releases/download/v0.4/ssm-parent_0.4_linux_amd64.tar.gz && \
tar xvf /tmp/ssm-parent.tar.gz && mv ssm-parent /sbin/ssm-parent && rm /tmp/ssm-parent.tar.gz

YPOINT ["/sbin/ssm-parent", "run", "-e", "-p", "/$PROJECT/$ENVIRONMENT/backend/", "-r",  "--"]
["caddy" , "--conf", "/etc/Caddyfile", "--log", "stdout"]
Config generation

If your application can't be configured via environment variables, then the following script, utilising envsubst, can be used to generate configs.

in/sh

 "Bootstrapping Caddy"
ubst < /etc/Caddyfile.env > /etc/Caddyfile

 $@
How to build

This project uses https://github.com/golang/dep as a dependency manager. Go v.1.10.1 was used.

$git clone https://github.com/springload/ssm-parent.git
$cd ssm-parent && dep ensure
$go build
# (after some hacking)
$git tag vXXX && git push && git push --tags
$goreleaser # to create a new release

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.