Skip to main content

Service Environment Variables

Nar provides environment variables to every service at runtime. Variables come from two sources: infrastructure that Nar discovers automatically, and your nn_env.json configuration files.

All JSON values are converted to strings: arrays become comma-separated, booleans become "true" or "false", and nulls become empty strings.


Variables Nar Provides

VariableExampleDescription
SERVICE_AWS_REGIONus-east-1The region where this service is deployed.
sitedevThe site name.
{PREFIX}_BUCKETperm-dev-ral-us-east-1-059279877465One variable per S3 bucket prefix defined in buckets.json (e.g., PERM_BUCKET, SCRA_BUCKET).
{SERVICE}_SERVICE_URLhttps://auth.us-east-1.dev.ral.narambu.comURL of each sibling service defined in services.lambda[] (e.g., AUTH_SERVICE_URL, SBCS_SERVICE_URL).

Any values you define in nn_env.json are also injected as environment variables.


nn_env.json — Global Config

{vertical}/services_config/nn_env.json applies to all services.

Example:

{
"JWT_ALGORITHM": "HS256",
"JWT_SECRET": "your-secret-here",
"GOOGLE_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
"GOOGLE_CLIENT_SECRET": "your-client-secret"
}

nn_env.json — Per-Service Config

Each service can have its own {vertical}/{service}/config/nn_env.json. These values override the global config for that service only.


Merge Priority

When the same key appears in multiple sources, the highest-priority source wins:

PrioritySourceScope
1 (highest){vertical}/{service}/config/nn_env.jsonPer-service
2{vertical}/services_config/nn_env.jsonAll services
3 (lowest)Nar-providedBuckets, service URLs, region, site

Example

A service deployed to site dev with the above configuration would see:

SERVICE_AWS_REGION=us-east-1
site=dev
IMAGES_BUCKET=images-dev-ral-us-east-1-059279877465
PERM_BUCKET=perm-dev-ral-us-east-1-059279877465
AUTH_SERVICE_URL=https://auth.us-east-1.dev.ral.narambu.com
SBCS_SERVICE_URL=https://sbcs.us-east-1.dev.ral.narambu.com
JWT_ALGORITHM=HS256
JWT_SECRET=your-secret-here
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret