# How to update Lambda environment variables

How-to guides · Updated 16 November 2026

**Short answer:** In the Lambda console, open the function's Configuration tab, choose Environment variables, Edit, change the values and save. From the CLI, aws lambda update-function-configuration --environment sets them, but it replaces the whole set: any variable you leave out is deleted. Read the current values first and merge. Changes apply to $LATEST; publish a version and move your alias if callers use one.

## Read the current values

```
aws lambda get-function-configuration --function-name checkout \
  --query 'Environment.Variables'
```

For a specific version or alias, add `--qualifier live`. Values are shown in plain text to anyone allowed to call `GetFunctionConfiguration`, which is one reason not to keep secrets here.

## Change one variable without losing the rest

```
# 1. Save the current set
aws lambda get-function-configuration --function-name checkout \
  --query 'Environment' > env.json

# 2. Merge your change (needs jq)
jq '.Variables.LOG_LEVEL = "debug"' env.json > env-new.json

# 3. Apply the full set
aws lambda update-function-configuration --function-name checkout \
  --environment file://env-new.json

# 4. Wait for the update to finish before the next change
aws lambda wait function-updated --function-name checkout
```

Writing the variables inline is fine for a function with only a couple of them: `--environment "Variables={LOG_LEVEL=debug,TABLE_NAME=orders}"`. Just remember it is the complete list.

Removing a variable works the same way: `jq 'del(.Variables.OLD_FLAG)' env.json`, then apply the result. To clear every variable, pass `--environment '{"Variables":{}}'`.

## Console steps

1. Open the Lambda console and select the function.
2. Choose the **Configuration** tab, then **Environment variables**, then **Edit**.
3. Add, change or remove keys and values, and save. The console sends the full set for you, so other variables are kept.

New invocations pick up the values as soon as the update completes; warm execution environments are replaced rather than updated in place.

## Versions, aliases and deploy tools

- **Published versions are immutable.** If an alias such as `live` points to version 12, changing `$LATEST` has no effect on traffic until you publish a new version and move the alias ([publish-version](https://cloudconsole.dev/cli/lambda-publish-version), then [update-alias](https://cloudconsole.dev/cli/lambda-update-alias)).
- **Infrastructure as code wins.** If SAM, CDK, Terraform or CloudFormation manage the function, a manual change is overwritten on the next deploy. Change it in the template.
- **Rollback:** because versions snapshot configuration, moving the alias back restores the old variables too; see [rolling back a Lambda version](https://cloudconsole.dev/how-to/roll-back-lambda-version).

## Limits and mistakes

- **Size:** all variables together are limited to 4 KB. Larger configuration belongs in Parameter Store, AppConfig or S3.
- **Reserved names:** keys such as `AWS_REGION` and `AWS_LAMBDA_FUNCTION_NAME` are set by Lambda and can't be overridden.
- **Secrets:** environment variables are encrypted at rest, but readable by anyone with configuration access. Store secrets in Secrets Manager or Parameter Store and fetch them at start-up.
- **`ResourceConflictException`** means another update is still in progress; wait with `aws lambda wait function-updated`. See [ResourceConflictException](https://cloudconsole.dev/errors/lambda-resourceconflictexception).
- **Typos in keys** fail silently: the function just sees no value. Read the configuration back after each change, and make the code fail fast when a required variable is missing.

## Questions

### Does update-function-configuration overwrite existing environment variables?

Yes. The --environment value replaces the entire set, so include every variable you want to keep.

### How do I get Lambda environment variables with the AWS CLI?

aws lambda get-function-configuration --function-name my-function --query Environment.Variables returns them as JSON.

### Do I need to redeploy after changing Lambda environment variables?

No code redeploy is needed for $LATEST. If traffic goes through an alias to a published version, publish a new version and point the alias at it.

## When this happens away from your desk

Flipping a log level or a feature flag is a small change that is often needed in a hurry. CloudConsole, a phone app for AWS, is built to show function configuration and errors on your phone, with production guardrails on any change.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Working with Lambda environment variables](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html)
- [UpdateFunctionConfiguration API reference](https://docs.aws.amazon.com/lambda/latest/api/API_UpdateFunctionConfiguration.html)

## Related

- [aws lambda update-function-configuration](https://cloudconsole.dev/cli/lambda-update-function-configuration)
- [aws lambda get-function](https://cloudconsole.dev/cli/lambda-get-function)
- [aws lambda publish-version](https://cloudconsole.dev/cli/lambda-publish-version)
- [ResourceConflictException: The operation cannot be performed at this time. An update is in progress](https://cloudconsole.dev/errors/lambda-resourceconflictexception)
- [How to roll back a Lambda version](https://cloudconsole.dev/how-to/roll-back-lambda-version)
- [aws ssm get-parameter](https://cloudconsole.dev/cli/ssm-get-parameter)

---

Source: https://cloudconsole.dev/how-to/update-lambda-environment-variables

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
