0
votes

I have a lambda application using serverless to deploy. The structure is shown as below:

apps/
apps/package.json
apps/serverless.yml

layers
layers/package.json
layers/serverless.yml

There are two folders apps and layers. In the layers, it defines the lambda layer infra. And in apps, it is the application code. I usually go to layers folder then run serverless deploy command which gives me the layer ARN. Then I paste the ARN to apps/serverless.yml manually. I am looking for a pattern which can take the layer ARN automatically. How can I do that in serverless?

1

1 Answers

0
votes

You can export the layer output and reference the output in the app serverless.yml

My layer serverless.yml

service: gt-layers
layers:
  ffmpeg:
    path: layer

resources:
  Outputs:
    FfmpegLayerExport:
        Value:
          Ref: FfmpegLambdaLayer
        Export:
          Name: FfmpegLambdaLayer

My App serverless.yml

  video_upload_notification:
    handler: handler.video_upload_notification
    layers:
      - ${cf:gt-layers-${self:provider.stage}.FfmpegLayerExport}

You can refer the blog here