Updating Lambda function to a new runtime
Asked Answered
I

3

5

I have few Lambda Functions with Python 3.6 runtime. These Lambda functions belongs to their Lambda applications.

What is the best way to update the runtime to Python 3.8 or latest? How to test it ? All lambda functions are relating to our continuous deployment process.

Would updating Lambda Function will update the Lambda Application runtime as Lambda application is simply Lambda function with resources ?

Any help is appreciated

Intervale answered 22/4, 2022 at 3:39 Comment(0)
D
6

To do it in the AWS Console, go to the Lambda console, find your function and click on its name. (e.g., eu-west-1 console). Scroll down toward the bottom of the page and look for "Runtime settings". Click "Edit" and then you can pick the new runtime from the available runtimes in the list.

Alternatively, you can use the command line to find all the Lambda functions that have the python3.6 runtime:

aws --region REGION lambda list-functions \
  --query 'Functions[?Runtime == `python3.6`].FunctionName'

That command will return a list of function names that have the python3.6 runtime.

Note that Lambda is a regional service, so you have to run that command line in each region where you've deployed Lambda functions, and change the value of REGION to something like eu-west-1 to check for functions in that region.

If you're super confident and just want to YOLO it, you can then run this command to update the runtimes on the functions. For each function Name that you got from the prior command, do this:

aws --region REGION lambda update-function-configuration \
  --function-name "FUNCTION-NAME" --runtime 'python3.8'

You have to put the value for your region and the value of the function name in the CLI.

If you're deploying your lambdas via CloudFormation or CDK, you don't do this at all. You update your CloudFormation or your CDK, and then you make a ChangeSet and then you deploy the ChangeSet.

Desmarais answered 28/9, 2022 at 21:2 Comment(0)
V
3

You can also change the runtime from AWS Management Console on the lambda's detail page: scroll down to the "Runtime settings" section and click "Edit".

How to change lambda runtime on AWS Console

Vachell answered 3/9, 2023 at 8:33 Comment(0)
D
1

Python ensure a perfect retro-compatibility between versions.

This doesn’t mean that you don’t have to test, but that you can be really confident in the upgrade process.

You should first review the changelog for the versions you are bumping (so if from 3.6 to 3.8, review 3.7 and 3.8 changelogs).

You should test then. Either locally, if it makes sense, by creating a main that will call the handler, or by putting in lambda and testing in real conditions.

You will modify the definition (whatever it is, directly in the aws console, in SAM, in serverless framework, in cloudformation or whatever).

If something gets wrong, you should revert to 3.6 to have your process working and investigate separetely.

Dalhousie answered 22/4, 2022 at 7:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.