npm.io
1.0.0 • Published 3d agoCLI

ssm-to-env-cli

Licence
MIT
Version
1.0.0
Deps
1
Size
5 kB
Vulns
0
Weekly
0

config-loader-demo

A CLI tool that loads AWS SSM Parameter Store values and outputs them as JSON, .env format, or shell exports. Built on top of aws-parameters-store.

Usage

# Output as JSON (default)
npx ts-node src/index.ts /myapp/production/

# Output as .env key=value pairs
npx ts-node src/index.ts /myapp/staging/ --format env

# Output as shell exports (useful for sourcing)
npx ts-node src/index.ts /myapp/dev/ --format export >> .env

# Specify region
npx ts-node src/index.ts /myapp/production/ --region eu-west-1

How it works

  1. Calls getParams(namespace, { region }) from aws-parameters-store
  2. Gets back a nested object based on the SSM parameter path hierarchy
  3. Flattens + formats into the desired output (JSON, env, or export)

Example

Given these SSM parameters:

/myapp/prod/database/host = "db.example.com"
/myapp/prod/database/port = "5432"
/myapp/prod/redis/url = "redis://cache:6379"
/myapp/prod/features/dark_mode = true

Running:

npx ts-node src/index.ts /myapp/prod/ --format env

Outputs:

DATABASE_HOST=db.example.com
DATABASE_PORT=5432
REDIS_URL=redis://cache:6379
FEATURES_DARK_MODE=true

Keywords