Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Inject AWS SSM Parameters as Environment Variables

License

NotificationsYou must be signed in to change notification settings

gmr/env-aws-params

Repository files navigation

Build Status

env-aws-params is a tool that injects AWS EC2 Systems Manager (SSM)Parameter StoreKey / Value pairs asEnvironment Variableswhen executing an application. It is intended to be used as a DockerEntrypoint,but can really be used to launch applications outside of Docker as well.

The primary goal is to provide a way of injecting environment variables for12 Factor applications that have their configuration definedin the SSM Parameter store. It was directly inspired byenvconsul.

Example Usage

Create parameters in Parameter Store:

aws ssm put-parameter --name /service-prefix/ENV_VAR1 --value exampleaws ssm put-parameter --name /service-prefix/ENV_VAR2 --value test-value

Then useenv-aws-params to have bash display the env vars it was called with:

env-aws-params --prefix /service-prefix /bin/bash -cset

If you want to include common and service specific values,--prefix can be specifiedmultiple times:

env-aws-params --prefix /common /bin/bash -cset

To get a plaintext output of your environment variables to use with other utilities, we can useprintenv:

env-aws-params --pristine --silent --prefix /service-prefix /usr/bin/printenv>~/some-file.sh

Which will write your environment variables in plain text, for example:

# ~/some-file.sh Contents:ENV_VAR1=exampleENV_VAR2=test-value

CLI Options

NAME:   env-aws-params - Application entry-point that injects SSM Parameter Store values as Environment VariablesUSAGE:   env-aws-params [global options] -p prefix command [command arguments]COMMANDS:     help, h  Shows a list of commands or help for one commandGLOBAL OPTIONS:   --aws-region value        The AWS region to use for the Parameter Store API [$AWS_REGION]   --prefix value, -p value  Key prefix that is used to retrieve the environment variables - supports multiple use   --pristine                Only use values retrieved from Parameter Store, do not inherit the existing environment variables   --sanitize                Replace invalid characters in keys to underscores   --strip                   Strip invalid characters in keys   --upcase                  Force keys to uppercase   --debug                   Log additional debugging information [$PARAMS_DEBUG]   --silent                  Silence all logs [$PARAMS_SILENT]   --help, -h                show help   --version, -v             print the version

Building

This project usesgo modules. To build the project:

go mod downloadgo mod verifygo build

Building an environment is also provided as a docker image based on Alpine Linux. See the Dockerfile for more information.

docker build -t env-aws-params;# Build the imagedocker run --rm -it -v$HOME/.aws/:/root/.aws/ env-aws-params [your options]

[8]ページ先頭

©2009-2025 Movatter.jp