sincecutoff.com
← all changes

sam --env-vars accepts .env file format

Introduced 2026-03-19 · score 0.97

HOW TO USE IT

When setting local environment variables for SAM, put global `KEY=value` entries in a `.env` file, then pass its path to `sam local invoke` or `sam local start-api` with `--env-vars`.

sam local invoke --env-vars .env
sam local start-api --env-vars .env

WHY THIS HELPS

Set environment variables for a local SAM workflow using a .env file.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.156.0
  • --env-vars, -n <PATH>: Path to a JSON or `.env` file with Lambda environment variable values; format is detected automatically. `.env` values apply globally; function-specific overrides require JSON.
  • Prerequisite: Create a `.env` file with `KEY=value` lines. Comments starting with `#` and quoted values are supported; `.env` files only support global variables.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card