How to ref the layer in serverless for AWS lambda

layers

I’ve:

layers:
  canvasLib:
    path: ../layers/canvas # required, path to layer contents on disk
    name: ${self:custom.prefix}-canvasLibLayer # optional, Deployed Lambda layer name
    description: Layer for canvas # optional, Description to publish to AWS
    compatibleRuntimes:
      - nodejs10.x
    allowedAccounts:
      - '*'
    retain: true
  nodeCanvas:
    path: ../layers/nodeCanvas # required, path to layer contents on disk
    name: ${self:custom.prefix}-nodeCanvasLayer # optional, Deployed Lambda layer name
    description: Layer for node-canvas # optional, Description to publish to AWS
    compatibleRuntimes:
      - nodejs10.x
    allowedAccounts:
      - '*'
    retain: true
functions
   layers:
      - { Ref: CanvasLibLambdaLayer }
      - { Ref: NodeCanvasLambdaLayer }
layers:
  test:
    path: layer
functions:
  hello:
    handler: handler.hello
    layers:
      - { Ref: TestLambdaLayer }

This is not working.

1 Like

This isn’t working for me either. I ran ls on my current directory and it showed that the opt directory was empty. Help!

According to https://www.serverless.com/framework/docs/providers/aws/guide/layers/ , it can only be referenced by ARN explicitly in cross services scenario. This looks a bit odd, or am I understanding this wrong?