forked from kelseyhightower/confd
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
area: backendBackend implementationsBackend implementationsarea: configConfiguration handlingConfiguration handlingenhancementNew feature or requestNew feature or requestpriority: lowLow priority itemLow priority item
Description
Summary
Enable dynamic backend selection based on environment, allowing the same configuration to work across development, staging, and production.
Motivation
Currently, switching backends between environments requires:
- Different config files per environment
- Environment-specific deployment scripts
- Wrapper scripts that modify confd configuration
This adds complexity and increases the chance of configuration drift.
Proposed Implementation
Environment-Based Backend Selection
# confd.toml
[backends]
default = "env" # Fallback backend
[backends.production]
type = "vault"
address = "https://vault.prod.example.com"
token = "${VAULT_TOKEN}"
[backends.staging]
type = "consul"
address = "consul.staging.example.com:8500"
[backends.development]
type = "env"
# Use environment variables in developmentSelection via:
# Environment variable
CONFD_ENV=production confd
# Command line flag
confd --env production
# Auto-detect from common env vars
# Checks: ENV, ENVIRONMENT, APP_ENV, RAILS_ENV, NODE_ENVPer-Template Backend Override
[template]
src = "app.conf.tmpl"
dest = "/etc/app/app.conf"
# Use different backends for different keys
[[template.keys]]
prefix = "/app/config"
backend = "consul"
[[template.keys]]
prefix = "/app/secrets"
backend = "vault"Backend Fallback Chain
[template]
src = "config.tmpl"
dest = "/etc/app/config"
keys = ["/app/*"]
# Try backends in order until one succeeds
backends = ["vault", "consul", "env"]Conditional Keys
[template]
src = "database.conf.tmpl"
dest = "/etc/app/database.conf"
[template.keys.production]
prefix = "/prod/database"
[template.keys.staging]
prefix = "/staging/database"
[template.keys.development]
prefix = "/dev/database"
fallback_to_env = trueEnvironment Detection
Auto-detect environment from:
--envflag (highest priority)CONFD_ENVenvironment variable- Common environment variables (ENV, ENVIRONMENT, etc.)
- Kubernetes namespace detection
- AWS tags or instance metadata
- Default fallback
Configuration Inheritance
[backends._base]
# Shared settings
timeout = "10s"
retry_count = 3
[backends.production]
_inherit = "_base"
type = "vault"
address = "https://vault.prod.example.com"
[backends.staging]
_inherit = "_base"
type = "vault"
address = "https://vault.staging.example.com"Benefits
- Single configuration file for all environments
- Reduced deployment complexity
- Easier local development (use env backend)
- Gradual backend migration support
- Multi-backend architectures (secrets in Vault, config in Consul)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: backendBackend implementationsBackend implementationsarea: configConfiguration handlingConfiguration handlingenhancementNew feature or requestNew feature or requestpriority: lowLow priority itemLow priority item