envhaul

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0

README

envhaul

Haul config and secrets from AWS into .env files.

CI Release Go Reference Coverage OpenSSF Scorecard License


envhaul generates the .env files for every part of your project from one reviewable config file. Plain values live in the config next to references to AWS SSM Parameter Store and Secrets Manager, which envhaul resolves using your named AWS profiles, across as many accounts as you need.

# envhaul.yaml
name: dev
aws_profile: acme-dev
aws_region: us-east-1
ssm_prefix: /acme/dev

components:
  api:
    env_file: services/api/.env
    vars:
      APP_ENV: development                                       # inline, committed
      STRIPE_SECRET_KEY: "{{ssm:api/STRIPE_SECRET_KEY}}"         # /acme/dev/api/STRIPE_SECRET_KEY
      OPENAI_API_KEY: "{{ssm:api/OPENAI_API_KEY@acme-shared}}"   # another account
      DATABASE_URL: "postgresql://{{secret:acme/dev/db#username}}:{{secret:acme/dev/db#password|urlencode}}@localhost/acme"
  web:
    env_file: web/.env
    vars:
      VITE_API_BASE_URL: "http://localhost:8000"
      VITE_SENTRY_DSN: "{{ssm:api/SENTRY_DSN@acme-shared|default:}}"
$ envhaul sync
wrote  services/api/.env  (4 vars)
wrote  web/.env           (2 vars)

Features

  • One config, every component. API, frontend, infrastructure and tooling each get their own .env, in variable order, from one file you can review.
  • Secrets stay in AWS. Only references are committed. Generated files are written atomically with mode 0600, and values never appear in logs.
  • Named profiles and multiple accounts. Each reference can name its own profile. SSO, assume-role and credential_process all work.
  • Templates and pipes. Build connection strings from several secrets, and apply urlencode, trim, base64, default: and more.
  • Safe workflows. validate checks the config offline with file:line:col errors, diff previews changes with values masked, and exec runs a command without writing secrets to disk.
  • Fast. Each value is fetched once per run, SSM reads are batched, and requests run concurrently.

Install

brew install davidtucker/tap/envhaul                       # macOS, Linux
scoop bucket add davidtucker https://github.com/davidtucker/scoop-bucket && scoop install envhaul  # Windows
go install github.com/davidtucker/envhaul/cmd/envhaul@latest
curl -fsSL https://raw.githubusercontent.com/davidtucker/envhaul/main/install.sh | sh   # verifies checksums and signatures
docker run --rm ghcr.io/davidtucker/envhaul --help

deb, rpm and apk packages and archives for every platform are on the releases page.

Quick start

envhaul init        # write a starter envhaul.yaml and git-ignore .env
envhaul validate    # check it offline
envhaul list        # show where every value comes from
envhaul diff        # preview changes (values masked)
envhaul sync        # write the .env files
Command What it does
sync [component...] Resolve values and write env files (--strict fails on missing values)
diff [component...] Show what would change; --show-values, --exit-code
get <component> <VAR> Print one resolved value
exec <component> -- cmd Run a command with the values in its environment, without writing a file
list [component...] Show each variable's source (offline, --json)
validate Check the config (offline)
init Create a starter config

Reference syntax

{{ scheme:path [#key] [@profile] [| fn[:arg]]... }}
Example Reads
{{ssm:api/KEY}} SSM parameter api/KEY, joined onto ssm_prefix
{{ssm:/abs/path:3}} SSM parameter at an absolute path, version 3
{{secret:db}} The whole Secrets Manager secret
{{secret:db#password}} One key of a JSON secret
{{ssm:api/KEY@shared}} Using the shared AWS profile
{{secret:db#pass|urlencode}} URL-encoded, e.g. for connection strings
{{ssm:opt|default:fallback}} fallback when missing or empty

Pipes: urlencode, base64, base64decode, trim, lower, upper, default:value. See the reference guide.

Documentation

Full documentation is at davidtucker.github.io/envhaul:

How it fits with other tools

envhaul focuses on one job: a reviewable, per-component map from variable names to values in AWS, resolved across accounts with your own profiles and written as .env files. It works alongside credential managers such as aws-vault, and differs from tools that encrypt secrets in the repository (sops) or sync them through a hosted service. See the FAQ for details.

Versioning

envhaul follows Semantic Versioning. From v1.0.0, config files with version: 1, command-line flags and --json output stay compatible across every v1.x release; deprecations warn for at least one minor release first. See the changelog.

Contributing

Contributions are welcome! Please read CONTRIBUTING.md and the Code of Conduct. Want another secret store? Open a new source proposal.

Report security issues privately; see SECURITY.md.

License

Apache License 2.0

Directories

Path Synopsis
cmd
envhaul command
Command envhaul generates .env files from a config file, resolving values from AWS SSM Parameter Store and Secrets Manager.
Command envhaul generates .env files from a config file, resolving values from AWS SSM Parameter Store and Secrets Manager.
internal
awsclient
Package awsclient loads and caches AWS SDK configurations per named profile and region, and turns common credential failures into actionable messages.
Package awsclient loads and caches AWS SDK configurations per named profile and region, and turns common credential failures into actionable messages.
brand
Package brand renders the envhaul banners in the brand colors.
Package brand renders the envhaul banners in the brand colors.
cli
Package cli implements the envhaul command-line interface.
Package cli implements the envhaul command-line interface.
config
Package config loads and validates envhaul configuration files.
Package config loads and validates envhaul configuration files.
dotenv
Package dotenv renders, parses and atomically writes .env files.
Package dotenv renders, parses and atomically writes .env files.
gitcheck
Package gitcheck reports whether generated files are ignored by git, so envhaul can warn before secrets end up in a commit.
Package gitcheck reports whether generated files are ignored by git, so envhaul can warn before secrets end up in a commit.
pipe
Package pipe implements the transformation functions that can be chained onto a reference with "|", e.g.
Package pipe implements the transformation functions that can be chained onto a reference with "|", e.g.
provider
Package provider defines the interface every value source implements and a registry that maps reference schemes to providers.
Package provider defines the interface every value source implements and a registry that maps reference schemes to providers.
provider/awssecrets
Package awssecrets reads values from AWS Secrets Manager.
Package awssecrets reads values from AWS Secrets Manager.
provider/awsssm
Package awsssm reads values from AWS Systems Manager Parameter Store.
Package awsssm reads values from AWS Systems Manager Parameter Store.
providers
Package providers assembles the built-in value providers.
Package providers assembles the built-in value providers.
resolve
Package resolve turns parsed config components into concrete values by fetching every reference from its provider and applying pipes.
Package resolve turns parsed config components into concrete values by fetching every reference from its provider and applying pipes.
template
Package template parses envhaul value templates.
Package template parses envhaul value templates.
version
Package version reports build information.
Package version reports build information.

Jump to

Keyboard shortcuts

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