ssmenv

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2017 License: MIT Imports: 14 Imported by: 0

README

ssmenv

ssmenv is a tool to use Amazon EC2 Systems Manager (SSM) Parameter Store as environment variables.

$ aws ssm put-parameter --name /Foo/BAR --type String --value hello
$ aws ssm put-parameter --name /Foo/BAZ --type String --value world
$ ssmenv exec --path /Foo sh -c 'echo $BAR, $BAZ'
hello, world

CircleCI Go Report Card codecov

Usage

ssmenv exec [--paths=PATH,PATH...] [--recursive] command ...
ssmenv get [--path=PATH] [--recursive] [--export] [name]
ssmenv set [--path=PATH] name=value ...
ssmenv replace --path=PATH [--recursive] name=value ...

Example

Set parameters.
name=value is a String type. name@=value is a SecureString type.

$ ssmenv set /Prod/DBNAME=prod /Prod/DBPASS@=passw0rd
PUT /Prod/DBNAME=prod
PUT /Prod/DBPASS@=****************

You can also set parameters from STDIN.

$ cat <<EOF > envfile
> /Staging/DBNAME=staging
> # comment lines begin with #
> /Staging/DBPASS@=pwd
> EOF

$ ssmenv set < envfile
PUT /Staging/DBNAME=staging
PUT /Staging/DBPASS@=****************

Set parameters with --path option.

$ ssmenv set --path /Common AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID@=AKIAFOOBAR
PUT /Common/AWS_REGION=us-east-1
PUT /Common/AWS_ACCESS_KEY_ID@=****************

Get all parameters.

$ ssmenv get --recursive
/Common/AWS_ACCESS_KEY_ID@=AKIAFOOBAR
/Common/AWS_REGION=us-east-1
/Prod/DBNAME=prod
/Prod/DBPASS@=passw0rd
/Staging/DBNAME=staging
/Staging/DBPASS@=pwd

Execute the command with environment variables.

$ ssmenv exec --paths /Common,/Prod env
(snip)
AWS_ACCESS_KEY_ID=AKIAFOOBAR
AWS_REGION=us-east-1
DBNAME=prod
DBPASS=passw0rd

$ ssmenv exec --paths /Common,/Prod rails server

You can also export environment variables instead of executing the command directly.

$ ssmenv get --path /Prod --export
export DBNAME=prod
export DBPASS=passw0rd

$ $(ssmenv get --path /Common --export)
$ $(ssmenv get --path /Prod --export)
$ rails server

Replace all the parameters of the given path.

$ ssmenv replace --path /Prod DBNAME=prod DB_PASS@=passw0rd
UNCHANGED /Prod/DBNAME=prod
PUT /Prod/DB_PASS@=****************
DELETE /Prod/DBPASS

Other examples are in main_test.go.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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