Skip to content

Config ​

Turna configuration is decoded into four main sections: loads, preprocess, server, and services.

yaml
log_level: info
print: "turna started for {{ .APP_NAME }}"

loads: []
env: {}
env_values: []
preprocess: []
server: {}
services: []
telemetry: {}

Startup Order ​

Turna applies configuration and runtime work in this order:

  1. Load bootstrap settings from environment variables.
  2. Load Turna application config from the application config sources: Consul, AWS, Azure, Vault, GCP, HTTP, file, and environment.
  3. Run loads and store loaded data in template memory.
  4. Apply top-level env_values and env to Turna's own process environment, then refresh the default HTTP transport's proxy settings.
  5. Run preprocess modules.
  6. Render and write the top-level print message to logs when configured.
  7. Initialize telemetry and start server entrypoints and routers.
  8. Start services.

Dynamic loads can update loaded data later. When that happens, Turna refreshes template data and service filters.

Top-Level Fields ​

FieldTypeDescription
log_levelstringApplication log level. Default is info.
printstringTemplate rendered after loads and preprocess complete.
loadsarrayExternal data loaders. See Loads.
envobjectSet or overwrite Turna's process environment after loads. Values support templates.
env_valuesarray/-separated paths to maps in loaded data to export as process environment. Later paths override earlier ones; env has final precedence. Missing or non-map paths fail startup.
preprocessarrayPre-start file processors. See Preprocess.
serverobjectHTTP/TCP server configuration. See Server.
servicesarrayLocal commands to run. See Services.
telemetryobjectOpenTelemetry exporter settings. See Telemetry.

The debug loaded config log respects log:"-" struct tags: tagged fields are omitted, while other fields keep their cfg names. This does not affect configuration decoding. Process/service environment maps, inline loader content, credentials, private keys and marked authentication fields are excluded. This is not a general string scrubber: avoid putting secrets in unmarked fields such as commands or URLs, or in explicit print templates.

Process Environment ​

yaml
loads:
  - name: settings
    statics:
      - content:
          content: |
            environment:
              OTEL_SERVICE_NAME: turna-proxy
env_values:
  - settings/environment
env:
  HTTPS_PROXY: http://proxy.internal:8080

These settings add or overwrite variables in Turna itself, not just child services. Unspecified variables are preserved; an empty value sets an empty variable rather than removing it. Values are rendered and validated before environment changes are applied. Templates see the environment from before this step, so do not rely on one entry referencing another via env.

This runs once at startup. Dynamic loads do not reapply environment settings. It does not re-decode already-loaded application config, reinitialize clients, or change the parent shell. Child services inherit these variables according to their inherit_env setting and can override them with their own env.

Only components that read the environment after this step observe the new values. In particular, gcp_token reads credentials, certificates and audience from its middleware config, not automatically from environment variables; setting a GCP environment variable does not replace those fields or invalidate cached tokens.

After applying environment settings, Turna replaces the default HTTP transport with a clone whose proxy function reads a fresh snapshot of HTTP_PROXY, HTTPS_PROXY and NO_PROXY (and their lowercase equivalents). This bypasses Go's process-wide proxy environment cache, even if loads already made HTTP requests. Middleware clients that subsequently use or clone the default transport, including gcp_token, use the new proxy settings. Existing clients with their own transports and clients with explicit proxy settings are unaffected. The proxy snapshot is not refreshed on dynamic reload.

Telemetry ​

telemetry configures the global OpenTelemetry meter and tracer providers with github.com/rakunlabs/tell. Metrics and traces are exported over OTLP/gRPC. Without a collector address (and without OTEL_EXPORTER_OTLP_ENDPOINT) the providers are noop, so the telemetry middlewares cost almost nothing.

yaml
telemetry:
  collector: otel-collector:4317
  server_name: ""
  tls:
    enabled: false
    insecure_skip_verify: false
    cert_file: ""
    key_file: ""
    ca_file: ""
  metric:
    disabled: false
    default:
      go_runtime: true
  trace:
    disabled: false

Telemetry is recorded by the telemetry middlewares of HTTP, TCP and UDP. Service name and resource attributes follow the standard OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES environment variables.

Application Config Sources ​

Turna's own configuration (everything on this page) is loaded with github.com/rakunlabs/chu. Every source looks up a document named after the application, turna by default, and later sources override earlier ones:

OrderSourceEnabled whenDocument looked up
1defaultalwaysdefault struct tags
2consulCONSUL_HTTP_ADDR is setKV key <CONSUL_CONFIG_PATH_PREFIX>/turna
3awsssmAWS_REGION or AWS_DEFAULT_REGION is setparameter /<AWS_SSM_PREFIX>/turna
4awssecretsAWS_REGION or AWS_DEFAULT_REGION is setsecret <AWS_SECRETS_PREFIX>/turna
5azurekeyvaultAZURE_KEYVAULT_URL or AZURE_KEYVAULT_NAME is setsecret turna
6vaultVAULT_ADDR or VAULT_AGENT_ADDR is setKVv2 <VAULT_SECRET_BASE_PATH>/turna
7gcpparameterGCP_PROJECT_ID is setparameter turna
8gcpsecretGCP_PROJECT_ID is setsecret turna
9httpCONFIG_HTTP_ADDR is setGET <CONFIG_HTTP_ADDR>/turna<CONFIG_HTTP_SUFFIX>
10filealwaysturna.toml, .yaml, .yml or .json
11envalwaysenvironment variables and .env files

A source whose address variable is missing, or whose document does not exist, is skipped. Any other error, such as failed authentication, stops startup.

Remote documents are decoded as YAML, so JSON works as well.

sh
# Base config in Consul, secrets from GCP Secret Manager, overrides from env
CONSUL_HTTP_ADDR=consul:8500 \
CONSUL_CONFIG_PATH_PREFIX=finops \
GCP_PROJECT_ID=my-project \
LOG_LEVEL=debug \
turna

Naming ​

Environment variableDescription
APP_NAMEDocument name used by every source. Default is turna.
CONFIG_NAME_PREFIXPrepended to the name as <prefix>/<APP_NAME>.
CONFIG_SET_<SOURCE>Set to false to skip a source, for example CONFIG_SET_VAULT=false or CONFIG_SET_GCPSECRET=false. Useful when a backend is down and should not block startup.

File ​

Turna looks for turna.toml, turna.yaml, turna.yml or turna.json in the current directory, then in /etc. CONFIG_FILE_TURNA (the uppercased app name) or CONFIG_FILE points to a specific file instead.

sh
CONFIG_FILE=local.yaml turna

Environment ​

Environment variables are loaded last and override every other source. Field paths are uppercased and joined with _, so log_level is LOG_LEVEL and telemetry.collector is TELEMETRY_COLLECTOR. .env and .env.local in the current directory are read automatically; CONFIG_ENV_FILE adds one more file.

HTTP ​

Environment variableDescription
CONFIG_HTTP_ADDRBase URL. The app name is appended as a path.
CONFIG_HTTP_SUFFIXAppended after the name, for example .yaml.
CONFIG_HTTP_QUERYQuery string added to the request, for example env=prod.

Only a 200 response is used; 204 and 404 skip the source.

Consul ​

Environment variableDescription
CONSUL_HTTP_ADDRConsul address. Required to enable the source.
CONSUL_CONFIG_PATH_PREFIXKey prefix, the key becomes <prefix>/turna.

The client also reads the standard github.com/hashicorp/consul/api variables:

Environment variableDescription
CONSUL_HTTP_TOKEN_FILEFile containing the Consul token.
CONSUL_HTTP_TOKENConsul token.
CONSUL_HTTP_AUTHHTTP basic auth.
CONSUL_HTTP_SSLEnable TLS.
CONSUL_TLS_SERVER_NAMETLS server name.
CONSUL_CACERTCA certificate file.
CONSUL_CAPATHCA certificate directory.
CONSUL_CLIENT_CERTClient certificate.
CONSUL_CLIENT_KEYClient key.
CONSUL_HTTP_SSL_VERIFYTLS verification toggle.
CONSUL_NAMESPACEConsul namespace.
CONSUL_PARTITIONConsul partition.

Vault ​

Environment variableDescription
VAULT_ADDR, VAULT_AGENT_ADDRVault address. Required to enable the source.
VAULT_SECRET_BASE_PATHKVv2 mount path. Required when Vault is enabled.
VAULT_ROLE_IDAppRole role ID. When set, Turna logs in with AppRole; otherwise VAULT_TOKEN is used.
VAULT_ROLE_SECRETAppRole secret ID.
VAULT_APPROLE_BASE_PATHAppRole login path. Default is auth/approle/login.

The client also reads the standard github.com/hashicorp/vault/api variables:

Environment variableDescription
VAULT_TOKENVault token.
VAULT_MAX_RETRIESRetry count.
VAULT_CACERTCA certificate file.
VAULT_CACERT_BYTESCA certificate bytes.
VAULT_CAPATHCA certificate directory.
VAULT_CLIENT_CERTClient certificate.
VAULT_CLIENT_KEYClient key.
VAULT_RATE_LIMITClient-side rate limit.
VAULT_CLIENT_TIMEOUTClient timeout.
VAULT_SKIP_VERIFYSkip TLS verification.
VAULT_TLS_SERVER_NAMETLS server name.
VAULT_HTTP_PROXYHTTP proxy.
VAULT_PROXY_ADDRProxy address.
VAULT_DISABLE_REDIRECTSDisable redirects.

AWS ​

Both AWS sources use the default AWS credential chain (environment, shared config, IAM role).

Environment variableDescription
AWS_REGION, AWS_DEFAULT_REGIONRegion. Required to enable the sources.
AWS_SSM_PREFIXParameter Store prefix, the name becomes /<prefix>/turna. Loaded with decryption.
AWS_SECRETS_PREFIXSecrets Manager prefix, the secret id becomes <prefix>/turna.

Azure Key Vault ​

Uses DefaultAzureCredential (environment, managed identity, Azure CLI). The latest version of the secret is loaded; / in the name is replaced with -.

Environment variableDescription
AZURE_KEYVAULT_URLVault URL, for example https://my-vault.vault.azure.net/.
AZURE_KEYVAULT_NAMEVault name, used to build the URL when AZURE_KEYVAULT_URL is unset.

GCP ​

Both GCP sources use Application Default Credentials (GOOGLE_APPLICATION_CREDENTIALS, workload identity). / in the name is replaced with -.

Environment variableDescription
GCP_PROJECT_IDProject id. Required to enable the sources.
GCP_PARAMETER_LOCATIONParameter Manager location. Default is global.
GCP_PARAMETER_VERSIONParameter version to render. Default is latest. Referenced secrets are resolved server-side.
GCP_PARAMETER_FALLBACKWhen true and latest is disabled, use the most recent enabled version.
GCP_SECRET_LOCATIONSecret Manager location. Default is global.
GCP_SECRET_VERSIONSecret version. Default is latest.
GCP_SECRET_ADDITIONALComma-separated shared secrets loaded before turna, for example generic,keycloak. Missing ones are skipped.