Configuration is data that an application reads from outside its source code to decide how it should run and what services it should connect to. It usually changes between different environments (development, staging, production).
Common examples include:
-
Resource handles: Database connection strings, Redis or Memcached addresses, and other backing services.
-
Credentials: API keys for external services such as Stripe, AWS, or Twilio, and passwords for internal databases.
-
Per-deploy values: The public hostname for the application (for example,
api.myapp.comvs.localhost:3000) or the logging level (for example,DEBUGvs.ERROR).
The recommended way to store configuration data is in the form of environment variables. This is considered best practice for several key reasons:
-
Decoupling: You can change your configuration for different environments without changing a single line of code.
-
Security: Unlike configuration files, environment variables are less likely to be accidentally checked into a version control system like GitHub.
-
Language agnostic: Every operating system and programming language knows how to read environment variables. It’s a universal standard.