envilder exec reference
How do you run a command with secrets from AWS SSM or Azure Key Vault without writing a .env file? envilder exec resolves every secret in your map file and starts the command with those values added to its environment. If any secret cannot be resolved the command never starts and Envilder exits with 125; otherwise it exits with the command's own code.
Prerequisites
- The envilder CLI.
- A map file and read access to every mapped secret, exactly as for pull mode.
- The command to run, on your PATH or given with its path.
Synopsis
envilder exec [options] [--] <command> [args...]Where your command starts: the -- rule
Envilder options come first. Your command starts at the first argument that is not an Envilder option, or right after --. Everything after that is passed to it verbatim, even if it looks like an Envilder option. You only need -- when the command itself starts with -.
# Everything belongs to npm
envilder exec npm run dev
# --map is Envilder's, the rest is npm's
envilder exec --map=cfg.json npm run dev
# --map=x belongs to npm: it comes after the command
envilder exec npm run dev --map=x
# Same as above, with an explicit separator
envilder exec --map=cfg.json -- npm run devOptions
| Option | Description |
|---|---|
--map | Path to the map file (default: envilder.json) |
--profile | AWS CLI profile. Overrides $config.profile |
--provider | aws or azure. Overrides $config.provider |
--vault-url | Azure Key Vault URL. Overrides $config.vaultUrl |
Envilder options go after exec, never before it. An option written before exec is rejected with exit code 125, and Envilder shows the corrected command:
$ envilder --map=config/prod.json exec -- npm start
error: Put envilder options after "exec": envilder exec --map=config/prod.json -- npm …Exec mode never reads or writes a .env file and never pushes, so these options are rejected with exit code 125 before any provider call. An unknown option before your command is also an error, so a typo such as --mapp never reaches your command.
| Option | Message |
|---|---|
--envfile | --envfile cannot be used with exec: exec mode never reads or writes a .env file. |
--push | --push cannot be used with exec. |
--key, --value, --secret-path | Single-secret push options cannot be used with exec. |
Example
The map file declares DB_PASSWORD and API_TOKEN, and the shell already exports a DB_PASSWORD of its own. Start the app through Envilder:
envilder exec -- node app.jsOverriding inherited variables: DB_PASSWORD
envilder: 2 secrets resolved (aws) → node …Overriding inherited variables: DB_PASSWORD
envilder: 2 secrets resolved (azure, vault=my-vault.vault.azure.net) → node …All Envilder output goes to stderr, so stdout belongs to your command: envilder exec -- node print.js > out.json writes only its output. The summary names your command by program name only, because arguments can carry secrets. With a profile it reads (aws, profile=dev).
Exit codes
Exit codes follow GNU env and docker run, so you can tell an Envilder failure apart from your command's own exit code:
| Code | Meaning |
|---|---|
n | Your command exited with code n |
128 + n | Your command was killed by signal n (for example, 137 for SIGKILL) |
125 | Envilder failed before starting the command: bad options, missing command, no map file, unresolved secrets or expired credentials |
126 | The command exists but the operating system refused to run it (for example, Permission denied) |
127 | The command was not found |
Pull and push modes exit with 1 on failure.
Fail-closed resolution
If any secret is missing, empty or unreadable (for example, access denied), the command does not start: Envilder lists the affected variables with masked paths and exits with 125. Pull mode, by contrast, skips a missing secret. Output when one secret does not exist and another is empty:
🪙 RESOLVING SECRETS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ DB_PASSWORD → ***************ord
✓ API_TOKEN → ***************c21
💥 GAME OVER — some secrets could not be fetched
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✗ SENTRY_DSN → *******************dsn
✗ FEATURE_FLAG → *********************lag
⮕ WHY?
not found
empty- A secret value that contains a NUL byte is rejected, because an environment variable cannot hold one.
- On Windows, a map file that declares two names differing only by case (API_KEY and api_key) is rejected before any provider call, because Windows treats them as one variable. On Linux and macOS both are kept.
- A map file with no variables is not an error: Envilder prints Map file declares no variables. and starts the command with the inherited environment.
- Values are resolved once, before the command starts. A later change in the vault does not reach a running command.
Environment
Your command inherits the full environment of the shell that runs Envilder, plus every variable in the map file. The map file wins: when an inherited variable has the same name as a mapped one, your command sees the value from the provider, and Envilder prints the names (never the values) on stderr:
Overriding inherited variables: DB_PASSWORDOn Windows names are compared without case: an inherited Path and a mapped PATH are the same variable, the mapped value wins and the command gets a single entry. Values are passed byte for byte, with no quoting, escaping or expansion.
No shell is involved: arguments reach your command as a list. Your own shell still parses the line first, so an unquoted $DB_PASSWORD expands to your shell's value, not the secret, and an unquoted && runs outside envilder exec. For shell features, start a shell explicitly:
envilder exec -- sh -c 'echo $DB_PASSWORD'Expired AWS SSO sessions
When the AWS SSO session has expired and stdin and stderr are a terminal, Envilder offers to run aws sso login, then retries only the secret resolution: your command starts at most once. If you decline, the login fails or there is no terminal (in CI, for example), the exit code is 125. An error after the command has started is never retried.
Signals
stdin, stdout and stderr are inherited and the TTY is preserved, so REPLs and prompts work. Ctrl+C in a terminal reaches your command directly. SIGTERM and SIGHUP (from docker stop or Kubernetes, for example) are forwarded, and Envilder waits for the command to exit with no timeout of its own. Only the direct child receives them: a launcher such as npm must stop its own children.
CI and GitHub Actions
In CI, give the job cloud credentials first (for example with OIDC), then run the CLI in a run step. Only that step sees the secrets. The Envilder GitHub Action offers the same behavior through its command input.
permissions:
id-token: write # Required for OIDC
contents: read
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: "22.x"
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
aws-region: us-east-1
- run: npx envilder exec -- npm testWhen GITHUB_ACTIONS=true, Envilder registers every resolved value with GitHub log masking (::add-mask::) on stderr before your command starts, so values it prints are masked in the job log.
Do not redirect the stderr of envilder exec away from the step log (2>/dev/null, for example): the runner reads the masks from it.
package.json scripts
Put exec in your scripts so everyone starts the project the same way with npm run dev. Add envilder as a dev dependency (npm install --save-dev envilder) so the script finds it in node_modules/.bin:
{
"scripts": {
"dev": "envilder exec -- vite",
"start": "envilder exec --map=config/prod.json -- node server.js"
}
}Other common uses
Any tool that reads its configuration from the environment works the same way. Each line below runs with the secrets of envilder.json:
# Containers: -e NAME without a value copies it from the environment
envilder exec -- docker run --rm -e LOCALSTACK_AUTH_TOKEN -p 4566:4566 localstack/localstack:stable
envilder exec -- docker compose up
# Integration tests that read tokens from the environment
envilder exec -- npm test
# Migrations and one-off scripts that need DATABASE_URL
envilder exec -- npx prisma migrate deploy
# Terraform reads TF_VAR_<name> as the input variable <name>
envilder exec -- terraform plan
# Several commands with the same secrets
envilder exec -- sh -c 'npm run migrate && exec npm start'Docker Compose reads variable references in compose.yaml from its environment, so no .env file is needed; Docker keeps a container's environment in its metadata until the container is removed. Mark Terraform variables that hold secrets as sensitive.
envilder-examples · cliCommon errors
| Message | Fix |
|---|---|
error: Missing command. Usage: envilder exec [options] [--] <command> [args...] | Add the command after exec, or after --. |
error: unknown option '--mapp' (Did you mean --map?) | Fix the option name. Everything before your command must be an Envilder option; put your own flags after the command. |
No map file found. Provide --map or create envilder.json in the current directory. | Run envilder from the directory that holds envilder.json, or pass --map after exec. |
Command not found: vitee | Exit code 127. Check the program name and your PATH. On Windows, cmd.exe first prints its own "is not recognized" line. |
Permission denied: ./run.sh | Exit code 126. Make the file executable (chmod +x run.sh) or run it through its interpreter (sh ./run.sh). |
Map file declares variables that differ only by case (API_KEY, api_key); Windows treats them as the same variable. | Windows only. Rename one of the two variables. |
Secret for API_TOKEN contains a NUL byte and cannot be passed as an environment variable. | Remove the NUL byte from the secret, or read it in-process with an SDK. |