Principle:173TECH Sayn Settings Configuration
| Knowledge Sources | |
|---|---|
| Domains | Configuration_Management, DevOps |
| Last Updated | 2026-10-17 00:00 GMT |
Overview
Pattern for layered configuration resolution that merges YAML-based settings with environment variables, enabling profile-based environment switching and 12-factor compliance.
Description
Settings configuration is the practice of resolving runtime configuration through multiple layers: a YAML file for structured, profile-based settings and environment variables for deployment-specific overrides. This solves the problem of managing different configurations across development, staging, and production environments without modifying code or project files.
Key concepts:
- Profiles: Named configuration bundles (e.g., "dev", "prod") that encapsulate credentials, naming rules, and parameters
- Environment variables:
SAYN_*prefixed variables override or supplement YAML settings - Credential mapping: Profile credentials map settings.yaml names to project.yaml
required_credentials - Stringify rules: Per-profile prefix/suffix/override for database object naming (dev vs prod)
- from_prod: Glob patterns specifying which source tables should use production naming even in dev profiles
- default_run: Default CLI arguments (include/exclude/upstream_prod) per profile
Usage
Use this principle when an application needs environment-specific configuration that can come from both files and environment variables. It is the right choice for data platforms deployed across multiple environments where credentials and naming conventions differ.
Theoretical Basis
The layered configuration resolution follows a precedence chain:
- Base: Empty configuration
- YAML layer:
settings.yamlparsed intoSettingsYamlmodel, profile selected viaprofile_name - Environment layer:
SAYN_*env vars parsed intoEnvironmentmodel (only merged when no profile specified)
The profile resolution algorithm (get_profile_info):
- Resolve profile name (explicit or
default_profile) - Extract non-None stringify values (prefix/suffix/override)
- Map credential names from settings to project
- Return
from_prodglobs anddefault_runsettings
The environment variable regex:
SAYN_((DATABASE|SCHEMA|TABLE)_(PREFIX|SUFFIX|OVERRIDE))|FROM_PROD|DEFAULT_RUN|PARAMETER_<name>|CREDENTIAL_<name>
Practical Guide
A settings.yaml file:
credentials:
warehouse:
type: postgresql
host: localhost
port: 5432
api_db:
type: sqlite
path: ./data.db
profiles:
dev:
credentials:
warehouse: warehouse
api_db: api_db
schema_prefix: dev
from_prod:
- "raw.*"
prod:
credentials:
warehouse: warehouse_prod
api_db: api_db_prod
default_profile: dev
Environment variable override:
export SAYN_SCHEMA_PREFIX=staging
export SAYN_FROM_PROD="raw.*,external.*"