قالب وردپرس درنا توس
Home / Tips and Tricks / Manage different versions of Lambda functions – CloudSavvy IT

Manage different versions of Lambda functions – CloudSavvy IT



  lambda logo

Lambda functions are very useful access to AWS's calculation services. Since they are in fact just a feature in the cloud, tracking different versions and rolling out updates is crucial to working effectively with them.

$ LATEST Tracks The most recent updates

Whenever you make a change to a Lambda feature, changes are automatically reflected in a version called $ LATEST. This keeps track of the most recent updates and is the standard version for most Lambda functions. Lambda editing page, Cloud9 IDE and zip upload changes from the CLI all update this version.

Therefore, the $ LATEST version should not be used in production, as updates to the feature to test new features affect your production traffic. Additionally, there is no easy way to roll out updates over time with CodeDeploy if you use $ LATEST.

Instead, we recommend creating new versions for each release, and a & # 39; production & # 39; alias referring to it. $ LATEST can be used for development, with its own alias that also refers to it.

Add a new version (and move traffic to it)

Working with versions is quite easy. In the Lambda Management Console, select your function and click the "Version:" drop-down list. This allows you to switch between versions and view the versions that are currently in use.

 Lambda version menu

To publish a new version, switch to the $ LATEST version, and click "Publish new version" in the "Actions" drop-down list.

 lambda new version

New versions are indicated fairly archaic by an ascending integer, without using the default major.minor. .patch format used for most software versions. If you really need this format, we recommend using CodePipeline with SAM implementations and tracking your Lambda versions on Git.

This new version can be used in other services, such as API Gateway. However, you don't want every service using your Lambda feature to be updated every time the feature itself is updated. Instead, you must create an alias that points to a specific version number and can be set as an endpoint for API Gateway. This way, when you publish a new version, you only need to update the alias to switch everything.

You can create aliases from the same "Actions" menu. Give it a name, such as "Production", and select a version to refer to.

 lambda alias

Aliases can also gradually move traffic to a new version. Although you can set this manually, it is usually used for CodeDeploy deployments, where new versions of your functions can be implemented gradually, for example 10% every five minutes or so. This way you can spot errors early and roll back releases before they apply to everyone.

SAM Deployments Automatically Add New Versions

Manually Creating Versions is useful, but if you manage many functions you will probably be using SAM implementations. Lambda functions implemented with SAM templates automatically add a new version (and update $ LATEST).

Combined with Git for version control and AWS & # 39; s CodePipeline CI / CD service, this makes version control for Lambda functions much easier. Whenever a change is made to the release branch in your source control, CodePipeline is automatically activated and your functions are updated. If you are working with a language that needs to be compiled (or transpire in the case of TypeScript), you can also send your function code to CodeBuild to handle that phase as well.

SAM implementation is an extension of CloudFormation, so any deployments made with SAM create a new CloudFormation stack. Whenever updates are pushed, CloudFormation recognizes that it is a stack update instead of a new stack, replacing the current feature version with the updated version.


Source link