Search code examples
amazon-web-servicesaws-lambdaserverless-frameworkaws-serverless

How to update AWS lambda using serverless framework without downtime?


There is a following setup:

  • 2 lambda functions, deployed using serverless.yml
  • custom domain (e.g. api.mydomain.com) attached to API Gateway
  • 2 stages (dev and prod)
  • CNAME configuration in my domain to point to abcdefg.cloudfront.net

There's a high-level task to update two lambda functions without the downtime for the API that they are serving. How to do it using serverless framework?

Note: there are two ways to manage lambda deployments: stages and aliases (versions). Currently aliases do not work in serverless (there's a fork that hotfixes the issue, but it does not matter atm).


Solution

  • There is no downtime when updating a lambda function using the Serverless Framework, simply by running sls deploy.

    The function code is zipped and uploaded to Lambda, and when that is completed, CloudFormation will update the Lambda configuration to point to the new code. There is no downtime in this process.