Skip to content
SP StackPractices
beginner By StackPractices

Environment Configuration Template

A template to document environment variables, secrets, endpoints, and infrastructure settings per deployment environment.

Note: This guide follows English-language naming conventions and terminology standards common in international development teams. Examples use English identifiers and comments to maximize compatibility across codebases and tooling.

Overview

Every application runs in multiple environments such as development, staging, and production. Each environment has its own configuration, endpoints, secrets, and infrastructure settings. This template helps teams document those settings in one place, making onboarding, debugging, and disaster recovery easier.

When to Use

  • Setting up a new application or service.
  • Onboarding a new team member or contractor.
  • Preparing a deployment or migration plan.
  • Troubleshooting environment-specific bugs.
  • Auditing configuration drift between environments.
  • Creating a runbook for incident response.

Prerequisites

  • Access to the deployment platform or cloud console.
  • A list of services, databases, and third-party integrations the application uses.
  • Permission to view secrets and credentials, or a secure handoff process.
  • A naming convention for environment variables and configuration keys.
  • An understanding of compliance and security requirements for each environment.

Solution

Template

1. Environment Identification

FieldDescriptionExample
Application / ServiceName of the systemPayment API
Environmentdev, staging, production, etc.production
Region / ZoneGeographic deploymentus-east-1
Cluster / InstanceWhere the app runsprod-k8s-cluster-01
Version deployedCurrent releasev2.4.1
OwnerTeam responsiblePayments team
Last reviewedDate of last update2026-06-27

2. Core Environment Variables

VariablePurposedev Valuestaging Valueproduction ValueSecret
APP_ENVRuntime environmentdevelopmentstagingproductionNo
LOG_LEVELLogging verbositydebuginfowarnNo
API_PORTPort the service listens on80808080443No
DATABASE_URLConnection string for primary databasepostgres://dev-dbpostgres://staging-dbpostgres://prod-dbYes
REDIS_URLCache connection stringredis://dev-redisredis://staging-redisredis://prod-redisYes
JWT_SECRETSecret for token signingdev-secretstaging-secretprod-secretYes
EXTERNAL_API_KEYKey for third-party integrationtest-keytest-keylive-keyYes
FEATURE_FLAG_XToggle for new featuretruetruefalseNo

3. Service Endpoints

ServiceEnvironmentURL / HostPortProtocolNotes
Applicationproductionapi.payments.example.com443HTTPSBehind load balancer
Databaseproductionprod-db.internal.example.com5432PostgreSQLPrivate subnet
Cacheproductionprod-redis.internal.example.com6379RedisPrivate subnet
Message queueproductionprod-rabbit.internal.example.com5672AMQPPrivate subnet
Object storageproductions3://prod-payments-data443HTTPSEncrypted at rest

4. Infrastructure Settings

ResourcedevstagingproductionNotes
Compute1 small container2 medium containers4 large containersAuto-scaling in production
CPU / memory0.5 vCPU / 1 GB1 vCPU / 2 GB2 vCPU / 4 GBPer container
DatabaseShared dev instanceSingle staging instanceMulti-AZ clusterWith read replicas in production
CacheSingle dev nodeSingle staging nodeClustered productionRedis cluster mode
StorageStandard classStandard classInfrequent access tierLifecycle policy applied
NetworkPublic for dev toolsPrivate subnetPrivate subnet + NATVPN access required

5. Secrets and Credentials

Secret NameUsed ByStorage LocationRotation ScheduleLast Rotated
DATABASE_PASSWORDApplicationAWS Secrets ManagerQuarterly2026-06-01
JWT_SECRETApplicationHashiCorp VaultQuarterly2026-06-01
EXTERNAL_API_KEYIntegration serviceAzure Key VaultOn vendor rotation2026-05-15
TLS_CERTIFICATELoad balancerAWS ACMAnnual2026-04-20

6. Configuration Change Log

DateChangeAuthorReasonApproved By
2026-06-10Increased production cache cluster sizealice@example.comPrepare for flash salebob@example.com
2026-05-22Added FEATURE_FLAG_Xcarol@example.comRoll out new checkout flowdave@example.com
2026-05-01Rotated database credentialsplatform-teamQuarterly rotationsecurity-team

Explanation

A single source of truth for environment configuration reduces confusion and mistakes. When variables, endpoints, and secrets are documented, teams can deploy faster, debug issues across environments, and recover from incidents without guessing. The template also helps identify differences between environments, which is a common source of production bugs.

Variants

  • Microservices environment configuration: One document per service with cross-service endpoint references.
  • Infrastructure-as-Code environment configuration: Links to Terraform or CloudFormation variables files.
  • Container environment configuration: Focus on Docker compose, Kubernetes ConfigMaps, and Secrets.
  • Serverless environment configuration: Document function-level variables, API Gateway settings, and event sources.
  • Mobile app environment configuration: Document backend endpoints, API keys, and feature flags per build variant.
  • Database environment configuration: Focus on connection strings, replica endpoints, and backup settings.

Best Practices

  • Keep secrets out of version control and store them in a secure vault.
  • Use the same variable names across environments where possible.
  • Document why a value differs between environments.
  • Review and update the document after every significant deployment or infrastructure change.
  • Separate sensitive values from non-sensitive configuration.
  • Automate the generation of this document from infrastructure-as-code when possible.
  • Use a consistent naming convention for environment variables.
  • Include contact information for the environment owner.

Common Mistakes

  • Hard-coding environment-specific values in source code.
  • Storing secrets in plain text or unencrypted files.
  • Not updating the document after configuration changes.
  • Using different variable names for the same concept in different environments.
  • Mixing configuration for multiple environments in one file.
  • Omitting the reason for environment differences.
  • Not including third-party service endpoints or credentials.

FAQs

Should we store secrets in this document?

No. Store secret names and rotation schedules here, but keep actual values in a secure vault. This document should reference where to find secrets, not contain them.

How do we keep this document up to date?

Assign an owner and review the document after each deployment, infrastructure change, or quarterly. Link it to the change management process.

What is the difference between environment variables and configuration files?

Environment variables are typically used for values that change between environments or are sensitive. Configuration files are better for stable, structured settings that can be versioned.