Search forkrail

Search documentation, comparisons, and CLI commands.

Environment variables

Variables per environment and per branch, encrypted with a KMS key in your own AWS account. Production and preview values are never shown again once saved.

Three environments

EnvironmentUsed byValues readable?
ProductionProduction deploymentsNo: write-only, never shown or printed again
PreviewEvery other deployment (with optional per-branch values)No: write-only
DevelopmentYour own machine, through forkrail env pull or env runYes, for developers and above

Changes apply to the next deploy or redeploy, never to deployments that already exist. That’s what Redeploy is for.

Add and remove variables

In the dashboard, open the project’s Environment variables page. You can paste a whole .env file into the key field to fill in many at once. From the CLI, values come from stdin or a prompt and are never printed:

# Production and previews (the default without --target)
forkrail env add my-app DATABASE_URL
# One environment, from stdin
printf '%s' "$STRIPE_KEY" | forkrail env add my-app STRIPE_SECRET_KEY --target production
# Several at once
forkrail env add my-app API_URL --target preview,development
forkrail env ls my-app # names only
forkrail env rm my-app API_URL --target preview

--target (also -e or --environment) takes production, preview, development, or several comma-separated.

Values for one branch

A preview variable can be set for one Git branch, as on Vercel. That branch’s previews get its value instead of the preview value of the same name, and every other preview variable as usual.

forkrail env add my-app API_URL --git-branch feature/checkout
forkrail env rm my-app API_URL --git-branch feature/checkout

The branch is the one a deployment was made from: a push’s branch, or the branch checked out when you ran forkrail deploy. Production deployments never get branch values.

Local development

forkrail env pull # Development values into .env.local
forkrail env pull .env --environment preview # another file and environment
forkrail env run -- npm run dev # run a command with the values, no file written

An existing file is merged after you confirm (--yes in scripts). A new file is readable only by you, and the CLI warns when git doesn’t ignore it. Production and preview values can’t be read back, so they’re written empty for you to fill in.

System variables

Every deployment is told about itself, under Vercel’s names, so code moved from Vercel finds what it expects:

VariableValue
VERCEL1
VERCEL_ENV, VERCEL_TARGET_ENVproduction or preview
VERCEL_URLThe deployment’s own host
VERCEL_BRANCH_URLThe branch URL of a branch preview
VERCEL_PROJECT_PRODUCTION_URLThe production host
VERCEL_REGIONWhere it runs, as Vercel names it (iad1, fra1…)
VERCEL_DEPLOYMENT_ID, VERCEL_PROJECT_ID, VERCEL_PROJECT_NAMEThe deployment’s id and the project’s name
VERCEL_GIT_COMMIT_SHA, _REF, _MESSAGE, _AUTHOR_NAME, _REPO_OWNER, _REPO_SLUG, _PULL_REQUEST_IDThe commit, for deployments made from Git
FORKRAIL_ENV, FORKRAIL_URL, FORKRAIL_REGION (AWS name), FORKRAIL_DEPLOYMENT_ID, FORKRAIL_PROJECT_NAMEforkrail’s own names for the main ones

Builds get the same, plus CI=1 and VERCEL_GIT_PREVIOUS_SHA. Node apps run with NODE_ENV=production, previews too, as on Vercel. A variable you set yourself wins over a system variable of the same name. VERCEL_OIDC_TOKEN isn’t set; give the project an IAM role instead.

Names and limits

  • Names are letters, digits and _, not starting with a digit.
  • Reserved: AWS_LAMBDA_*, FORKRAIL_*, PATH, HOME, TEMP, TZ, PYTHONPATH and a few of Lambda’s own. You may set the AWS SDK’s AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN and AWS_REGION, as Vercel allows.
  • Up to 64 KB per environment, names and values together, as on Vercel. One value can take all of it.

Lambda’s own environment holds only 4 KB. When a deployment’s variables don’t fit, forkrail seals them in an encrypted (AES-256-GCM) file with a key made for that deployment, and your app reads them as usual. Nothing changes for your code.

Where values are kept

Each value is an AWS SSM SecureString parameter, encrypted with forkrail’s own KMS key in your account. Only identities you allow to decrypt with that key can read a value: the control function and your administrators. The routers, the dashboard and your apps can’t. Values are masked in build logs. The key costs $1 a month; the parameters are free.

Who can change what: developers change preview and development variables; members and owners change production’s too; viewers see names only. See Team and roles.

New to forkrail? Install it in your AWS account and deploy your first app in about 20 minutes.
Quickstart