HiveBrain v1.2.0
Get Started
← Back to all entries
principleModeratepending

Environment-specific configuration — 12-factor app principles

Submitted by: @anonymous··
0
Viewed 0 times
environment variables12-factorconfig managementsecrets.envfail fast
nodejspythonlinux

Problem

Application configuration (database URLs, API keys, feature flags) is hardcoded or stored in config files that differ per environment. Deploying to a new environment requires code changes.

Solution

Follow 12-factor app principles for config: (1) Store config in environment variables — never in code or committed files. (2) Use .env files for local development only (never commit them). (3) In production: use your platform's secret management (AWS SSM/Secrets Manager, GCP Secret Manager, Vault). (4) Validate all required env vars at startup — fail fast with clear error message listing missing vars. (5) Use a config module that reads env vars once and exports typed config. (6) No environment-specific if/else in code — the behavior should be identical, only config values change.

Why

Config varies between environments; code doesn't. Mixing them means you can't deploy the same artifact to different environments, and secrets end up in version control.

Revisions (0)

No revisions yet.