Can I change the environment variables in a published version of my Lambda function?
Last updated: 2020-02-18
I want to change the environment variables in a published version of my AWS Lambda function. Can I do that?
Resolution
You can't change the configuration (including environment variables) or function code in a published Lambda function version. You can only change the current, unpublished function version ($LATEST).
Change the unpublished function version
To change environment variables in the $LATEST version of your Lambda function, you can use:
- The Lambda console.
- The update-function-configuration command in the AWS Command Line Interface (AWS CLI).
- Lambda API calls in the AWS SDKs.
Publish a new function version
After changing environment variables in the $LATEST version, you can publish your updated Lambda function using the Lambda console or the PublishVersion API. For more information, see Managing Versions with the Lambda API.
Note: Consider creating a Lambda alias to point to a function version that's configured with the environment variables that you want to use. By using aliases, you can avoid hard-coding a specific function version into your app.
Related Information
UpdateFunctionConfiguration (AWS Lambda Developer Guide API Reference)
Environment (AWS Lambda Developer Guide API Reference)
Did this article help you?
Anything we could improve?
Need more help?