sincecutoff.com
← all changes

cargo-lambda deploy merges environment variables with --merge-env

Introduced 2026-02-15 · score 0.96

HOW TO USE IT

When deploying a function and remote environment variables must be preserved, run `cargo lambda deploy --merge-env` with the function name and the environment variables to add or update. Existing remote variables remain; local values take precedence for duplicates.

cargo lambda deploy --merge-env --env-var NEW_VAR=VALUE <function-name>
cargo lambda deploy --merge-env --env-vars FOO=BAR,BAZ=QUX <function-name>
cargo lambda deploy --merge-env --env-file <path> <function-name>

WHY THIS HELPS

Deploy a function while preserving environment variables managed outside Cargo Lambda.

BEFORE THIS CHANGE

Without `--merge-env`, deployment overwrites existing remote environment variables with the variables specified in configuration.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.9.0
  • --merge-env: Preserve existing remote environment variables; variables in local configuration are added or updated, with local values taking precedence for duplicates.
  • --env-var KEY=VALUE: Set environment variables using KEY=VALUE. May be repeated; docs say it overrides --env-vars and cannot be combined with it.
  • --env-vars KEY=VALUE,...: Set environment variables from a comma-separated list. Cannot be combined with --env-var.
  • --env-file <path>: Read environment variables from a file with one KEY=VALUE per line.
  • function-name (required): Function name argument for the deploy command.
  • merge_env: Cargo.toml deploy metadata boolean; `true` enables merging and the default is `false`.
  • Prerequisite: Build the function binary before deploying; deploy fails if it cannot find the binary.
  • Prerequisite: AWS account permissions for Lambda operations including `lambda:GetFunction`, `lambda:CreateFunction`, and `lambda:UpdateFunctionCode`; an IAM execution role with Lambda privileges is also required.
  • Merging is enabled by the `--merge-env` flag or `merge_env = true`; the configuration default is false.
  • When a variable is specified remotely and in configuration, the local value takes precedence.

FIRST-PARTY EVIDENCE

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

Report a problem with this card