agutoli / serverless-layers

Serverless.js plugin implementing AWS Lambda Layers, reducing lambda size, warm-up, and deployment time.
MIT License
229 stars 54 forks source link

Associate multiple layers with different functions #29

Closed CartierDiamonds closed 4 years ago

CartierDiamonds commented 4 years ago

Currently in my serverless.yml i have 2 functions defined but i only want my custom layer to be associated with 1 of the functions. Is it possible to define multiple layers and choose which layer is associated with which lambda?

agutoli commented 4 years ago

@CartierDiamonds I just pushed a new version with that feature.

Can you try 2.1.x version, please?

Usage Example

custom:
  serverless-layers:
    # applies for all lambdas 
    - common:
        dependenciesPath: ./my-folder/package.json
    # apply for foo only
    - foo:
        functions:
          - foo
        dependenciesPath: my-folder/package-foo.json
    - staticArn:
        functions:
          - foo
          - bar
        arn: arn:aws:lambda:us-east-1:<your_account>:layer:node-v13-11-0:5

functions:
  foo:
    handler: handler.hello
  bar:
    handler: handler.hello

plugins:
  - serverless-layers
agutoli commented 4 years ago
Screen Shot 2020-04-05 at 3 39 10 pm