Deploy lambda layer and lambda functions at the same time to maintain them synchronized

I have…

  • Lambda layer that will be used across many other services (common-layer)
  • Lambda functions for users/orders/payments/etc

In order to deploy stuff we need to go to the common-layer, hit serverless deploy and then go to the other services and hit serverless deploy as well. If we continue doing this, we cannot achieve synchronized data

services/layers/common-layer
services/[users,orders/payments/etc]/**

Within the common-layer I have a super important function that needs to be always synchronized with other lambda functions.

// services/layers/common-layer
function getSuperDuperHyperImportantNumber() {
  return 1;
}

// services/[users/orders/payments]
import { getSuperDuperHyperImportantNumber } from 'common-layer'

Later, specifications changed… Now we need rename the function to getCoolNumber and return 2 instead of 1

// services/layers/common-layer
function getCoolNumber() {
  return 2;
}

// services/[users/orders/payments]
import { getCoolNumber } from 'common-layer'
  • So, how can I deploy these changes simultaneously to maintain lambdas services and the common-layer synchronized?
  • Will serverless-compose help?

Notes:

  • Within the lambda services I’m using a serverless plugin to always point at the latest version of mentioned common-layer
  • This problem seems the same as the migrations stuff within databases-code