To speed up Serverless deployments, Seed incrementally deploys the Lambda functions in your service. It does this by checking if the CloudFormation template or Serverless config has been changed. If it hasn’t, then it’ll look at the individual Lambda functions in the service and deploy only the ones that have been updated. It’ll deploy the Lambda functions concurrently and directly, without doing a CloudFormation update.
Updating individual Lambda functions directly is a lot faster than having CloudFormation deploy the entire stack. To do this, Seed maintains an internal state of the deployed service using the Serverless Seed plugin.
Incremental Lambda Deploys is currently in beta.
To enable incremental deployments for your Lambda functions, first install the
$ npm install --save-dev serverless-seed
Then add it to your
And enable Incremental Lambda Deploys.
And that’s it.
Once enabled, the
serverless-seed plugin generates the state of the service when it’s deployed. This contains a hash of the CloudFormation template and Serverless config of the service. It also includes a list of all the Lambda functions in the service and their packages. Seed stores this information internally.
Now when you push a change, Seed will:
- Generate a new state file using the
- Check if the CloudFormation template or Serverless config has been updated.
- If they have, then it’ll proceed with the deployment as is.
- If they haven’t been updated, then it’ll do an Incremental Deploy.
- It’ll check which of the Lambda functions have been updated.
- And update them directly without doing a full CloudFormation deploy.
- Finally, it’ll save the new state of the service.
Incremental Lambda Deploys are automatically disabled for a deployment if:
- The previous build had failed
- The Force Deploy option was used
- The environment variables were updated
- There are no Lambda functions in the service
- The Lambda Layers in the service were updated
- Or, there was a problem generating the service state
It is recommended that you use Incremental Lambda Deploys in your development stages and do a full deployment in your prod or staging stages. To configure this, you can selectively disable it for certain stages.
serverless.yml, update the
serverless-seed config to.
disabledFor option takes a list of stage names that you want to disable incremental Lambda deployments for.