The environment registry type
The name of the variable (must be uppercase)
The union of all defined resolution types for this variable
The name of the variable (must be uppercase)
Array of resolution definitions for different environments
Static
createInternal
Creates a new Variable with the specified name.
The environment registry type
The name of the variable (must be uppercase)
The name of the variable (must be uppercase)
A new Variable with no environment definitions
Defines how this variable should be resolved for a specific environment.
The payload parameter is optional and depends on the resolution method type.
A new Variable with the added environment definition
const variable = Variable.create("DATABASE_URL")
.for("local", "from-env") // No payload needed
.for("workflows", "from-github-secrets") // No payload needed
const workflowVar = Variable.create("IS_WORKFLOW")
.for("local", "hardcoded", "false") // Payload required
.for("workflows", "hardcoded", "true") // Payload required
Defines this variable to use dynamic resolution for a specific environment.
Dynamic resolution allows the variable value to be provided at runtime when creating a resolver, rather than being hardcoded or derived from environment data.
The environment name to define dynamic resolution for
The name of the dynamic data property to use
A new Variable with the added dynamic environment definition
const variable = Variable.create("DOCUMENT_BUCKET")
.dynamicFor("local", "documentBucket")
.for("workflows", "hardcoded", "my-production-bucket")
// When creating a resolver, provide the dynamic data:
const resolver = varReg.createResolver("local", envData, {
documentBucket: "my document bucket name"
})
Represents a single environment variable with definitions for different environments.
The Variable class provides a fluent API for defining how a variable should be resolved in different environments. It supports both static resolution methods (hardcoded values, environment variables) and dynamic resolution (runtime values).
Example