Managing project-specific configurations and routing.
Environments provide a way to manage different configurations (e.g., Staging, Production) for your jobs and workflows within a single project.
Environment Model
The Environment struct (defined in apps/strait/internal/domain/types.go) includes:
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (UUIDv7). |
project_id | string | The project this environment belongs to. |
name | string | Human-readable name (e.g., "Production"). |
slug | string | URL-friendly identifier (e.g., "prod"). |
parent_id | string | Optional ID of a parent environment for variable inheritance. |
is_standard | bool | Whether this is a standard environment (development, staging, production). Standard environments cannot be deleted or renamed. |
variables | map[string]string | Key-value pairs for environment-specific configuration. Encrypted at rest when SECRET_ENCRYPTION_KEY is set. |
Standard Environments
Every project is created with three standard environments:
- Development (
development) - Staging (
staging) - Production (
production)
Standard environments cannot be deleted or renamed. Custom environments can be created as children of standard environments for more granular configuration.
Variable Inheritance
Environments support a hierarchical structure via the parent_id field.
- Inheritance: An environment inherits all variables from its parent.
- Overrides: If an environment defines a variable with the same key as its parent, the local value takes precedence.
- Resolution: Strait recursively resolves variables up the parent chain to provide a final, flattened set of variables at execution time.
Endpoint URL Overrides
One of the primary use cases for environments is routing the same job definition to different physical endpoints based on the environment.
- Mechanism: If an environment defines an
ENDPOINT_URLvariable, the executor will use this value instead of the job's defaultendpoint_url. - Dispatch Time: The override is resolved at the moment of dispatch, allowing for dynamic routing without modifying the job definition.
SSRF Validation
To prevent Server-Side Request Forgery (SSRF), all overridden URLs are strictly validated:
- Blocking: Private IP ranges (e.g.,
10.0.0.0/8,192.168.0.0/16) and loopback addresses (127.0.0.1) are blocked. - Layers: Validation occurs in both the API layer (during environment/job updates) and the Worker layer (during override resolution).
Use Case: Routing
Environments allow you to maintain a single job definition (e.g., process-order) while routing it to different services:
- Staging Environment:
ENDPOINT_URL=https://staging.api.myapp.com/jobs - Production Environment:
ENDPOINT_URL=https://api.myapp.com/jobs
The environment system resolves variables and URL overrides for jobs with an assigned environment.