I'm fairly new to AWS and serverless, so far I've been working with lambda functions and layers.
We have two services:
lambda1.yml
service: lambda1
provider: ...
functions:
hello:
handler: ...
name: ...
layers:
- { Ref: GlobalLambdaLayer }
layers:
global:
path: global_layer
lambda2.yml
service: lambda2
provider: ...
functions:
hello:
handler: ...
name: ...
layers:
- { Ref: GlobalLambdaLayer }
layers:
global:
path: global_layer
When I deploy lambda1 using 'sls deploy --config lambda1.yml', the layer is uploaded and assigned to lambda1 function succesfully.
However, when I deploy lambda2 using 'sls deploy --config lambda2.yml', Serverless uploads and creates a new layer. It doesn't reuse the one uploaded from lambda1.
According to my research, this is correct because each lambda function is declared in a different service.
My question is. Is my research correct?
I know I can create a separate service to hold my layer and share with both lambdas, as described here:
https://forum.serverless.com/t/layers-upload-on-each-deploy/6634/3
Nonetheless, I'm curious, is there a different way to do it? I can't put both lambdas in the same service. They need to be independent and share the same layer.
Thank you!