0.0.2 • Published 4 years ago

aws-secrets-to-env v0.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

This node.js script writes .env files or export commands to stdout based on values held in AWS Parameter Store and/or AWS Secrets Manager. Node applications can then be run using environment variables set by it, perhaps using package "dotenv" to retrieve from the .env file.

SAMPLE USAGE:

node aws-secrets-to-env.js \
--ssmpath=/myapp/prodconfig \
--secretid=/myapp/prodconfig \
--region=eu-central-1 \
>.env && node myapp.js

eval $(node aws-secrets-to-env.js \
--ssmpath=/myapp/prodconfig \
--secretid=/myapp/prodconfig \
--region=eu-central-1 \
--useexport \
) && node myapp.js
  • Specify ssmpath and/or secretid to retrieve from AWS Parameter Store and/or AWS Secrets Manager respectively.
  • You can specify --accessKeyId=awsAccessKeyId and --secretAccessKey=awsSecretAccessKey; otherwise default AWS auth is used.
  • For the Parameter Store, parameters are returned by path (e.g. parameters with names starting with an arbitrary path such as "/myapp/prodconfig")

SCRIPT OPTIONS

  • --ssmpath : AWS Param Store Path to retrieve
  • --secretid : AWS Secrets Manager secret ID to retrieve. (This should return JSON key/value pairs)
  • --debug : write debugging info to stderr
  • --help : display this message
  • --useexport : include an "export" command at the start of each line

AWS OPTIONS

All other options will be passed through to the AWS request. Useful options include:

  • --region : AWS region. Defaults to "eu-central-1"
  • --endpoint : specify an endpoint url (e.g. http://localstack:4566)
  • --accessKeyId
  • --secretAccessKey