liveBook · Manning

Environment variable

As explained in Grokking Software Architecture

An environment variable is a named runtime setting supplied through the process environment rather than embedded in application source code.

An environment variable supplies a secret to an application at runtime instead of embedding it in source code. Common uses include passwords, API keys, and database connection strings. section 11.8 section 8.7.3

Keep the secret out of the code, but make sure the surrounding security is sound:

  • For local development, store secrets in a .env file excluded from source control and load it with a suitable library, such as python-dotenv or dotenv for Node.js. section 11.8
  • For deployment, developer-focused platforms can inject secrets through encrypted environment-variable settings. Cloud compute can instead retrieve secrets through an assigned identity. section 11.5.2
  • Limit database account permissions too: keeping a password out of source code does not make an overprivileged account safe. section 11.8 section 8.7.3

How Grokking Software Architecture covers it

How deep it goes
Gives a security-audit procedure and local .env workflow, then names deployment injection without detailing variable syntax or application retrieval.
Examples
Uses a .env file excluded from source control, Python and Node.js dotenv libraries, and encrypted deployment settings on named platforms.
What you can do after
Operate local secrets by keeping values out of code and loading a .env file with a stack-appropriate library.
How it connects
Connects secrets management with configuration files, source control, .env libraries, and runtime secret delivery.

Also explained in

Compare how 24 books explain environment variable →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.