I have a serverless project that deploys 2 Lambdas in the same stack:
service: example-apis2 provider: name: aws memorySize: 512 region: us-west-1 apiGateway: restApiId: ${env:APIGWID} # API Gateway to add this api to restApiRootResourceId: ${env:RESOURCEID} functions: example2: handler: index2.handler layers: - arn:aws:lambda:us-west-1:[myaccountid]:layer:example-layer:1 events: - http: path: api2 method: get example3: handler: index3.handler layers: - arn:aws:lambda:us-west-1:[myaccountid]:layer:example-layer:1 events: - http: path: api3 method: get
After first deploy, if I do
aws lambda get-function --function-name example-apis2-dev-example2 ... "LastModified": "2021-10-27T06:30:31.002+0000",
and
$ aws lambda get-function --function-name example-apis2-dev-example3 ... "LastModified": "2021-10-27T06:30:31.987+0000",
Now if I make a code change only to the example 3 Lambda and redeploy only that function with:
serverless deploy function -f example-apis2-dev-example3
… example2 has not been modified since the first deploy (same timestamp as the original deploy):
$ aws lambda get-function --function-name example-apis2-dev-example2 ... "LastModified": "2021-10-27T06:30:31.002+0000",,
and only example3 shows it was updated/redeployed:
$ aws lambda get-function --function-name example-apis2-dev-example3 ... "LastModified": "2021-10-27T06:33:17.736+0000",
serverless deploy : deploys the whole stack (but if nothing has changed there is no update)
serverless deploy function -f functioname: updates just the code on that one Lambda (and updates in a couple of seconds vs several seconds for updating the whole stack).
This is described in this article here.