Configuration

sreq uses YAML configuration files stored in ~/.sreq/.

Configuration Files

FilePurpose
~/.sreq/config.yamlMain configuration (providers, defaults)
~/.sreq/services.yamlService definitions (optional, can be in config.yaml)

Full Configuration Example

# ~/.sreq/config.yaml

# Provider configurations
providers:
  consul:
    address: consul.example.com:8500
    token: ${CONSUL_TOKEN}
    datacenter: dc1
    # Environment-specific addresses (optional)
    addresses:
      dev: consul-dev.example.com:8500
      staging: consul-staging.example.com:8500
      prod: consul-prod.example.com:8500
    # Path templates for credential resolution
    paths:
      base_url: "services/{service}/{env}/base_url"
      username: "services/{service}/{env}/username"

  aws_secrets:
    region: us-east-1
    profile: default
    paths:
      password: "{service}/{env}/credentials#password"
      api_key: "{service}/{env}/credentials#api_key"

  env:
    paths:
      base_url: "{SERVICE}_BASE_URL"
      api_key: "{SERVICE}_API_KEY"

  dotenv:
    file: ".env"
    paths:
      base_url: "{SERVICE}_{ENV}_URL"
      password: "{SERVICE}_PASSWORD"

# Available environments
environments:
  - dev
  - staging
  - prod

# Default environment when -e is not specified
default_env: dev

# Contexts (presets for common configurations)
contexts:
  work:
    env: staging
    region: us-west-2
    project: backend
  personal:
    env: dev
    region: us-east-1

# Default context to use
default_context: work

# Service configurations
services:
  auth-service:
    consul_key: auth
    aws_prefix: auth-svc

  billing-service:
    consul_key: billing
    aws_prefix: billing

  # Advanced: explicit path mappings
  legacy-api:
    paths:
      base_url: "consul:legacy/api_url"
      username: "consul:legacy/user"
      password: "aws:legacy-creds/{env}#pass"

Path Templates

Path templates use placeholders that are replaced at runtime:

PlaceholderDescriptionExample
{service}Service nameauth-service
{env}Environmentdev, staging, prod
{region}AWS regionus-east-1
{project}Project namebackend
{app}App nameapi

Template Examples

paths:
  # Simple template
  base_url: "services/{service}/base_url"
  # → services/auth-service/base_url

  # With environment
  password: "{service}/{env}/password"
  # → auth-service/dev/password

  # AWS JSON key extraction (use #)
  api_key: "{service}/{env}/credentials#api_key"
  # → Fetches auth-service/dev/credentials, extracts .api_key from JSON

Service Configuration

Simple Mode

Use consul_key and aws_prefix with path templates:

services:
  auth-service:
    consul_key: auth        # Uses paths.base_url template with {service}=auth
    aws_prefix: auth-svc    # Uses paths.password template with {service}=auth-svc

Advanced Mode

Specify exact paths per credential:

services:
  custom-service:
    paths:
      base_url: "consul:custom/service/url"
      username: "consul:custom/service/user"
      password: "aws:custom-secrets/main#password"
      api_key: "aws:custom-secrets/main#api_key"

Path format: provider:path or provider:path#json_key

Contexts

Contexts are presets for common flag combinations:

contexts:
  production:
    env: prod
    region: us-east-1
    project: main

  development:
    env: dev
    region: us-west-2
    project: sandbox

default_context: development

Use contexts:

# Uses default_context settings
sreq run GET /api -s auth

# Override with specific context
sreq run GET /api -s auth -c production

# Override context values with flags
sreq run GET /api -s auth -c production -e staging

Environment Variables

VariableDescriptionDefault
SREQ_CONFIGConfig file path~/.sreq/config.yaml
CONSUL_HTTP_TOKENConsul ACL token
CONSUL_HTTP_ADDRConsul address
AWS_PROFILEAWS profiledefault
AWS_REGIONAWS region
SREQ_NO_CACHEDisable caching0
SREQ_NO_HISTORYDisable history0

Environment Variable Substitution

Use ${VAR} in config to reference environment variables:

providers:
  consul:
    token: ${CONSUL_TOKEN}
    address: ${CONSUL_HTTP_ADDR}

  aws_secrets:
    region: ${AWS_REGION}
    profile: ${AWS_PROFILE}

Validation

Test your configuration:

sreq config show     # Display current config
sreq config test     # Validate provider connections

Configuration Precedence

From lowest to highest priority:

  1. Default values
  2. config.yaml settings
  3. Context values (from -c or default_context)
  4. Environment variables
  5. Command-line flags

Next Steps