Lambda layer not attaching to function

I followed the example repo found here. The function deploys without issue however it does not have a layer attached per the Lambda console. I can manually add the layer from the console after the function has deployed. sls deploy -v doesn’t complain about anything. Any help is appreciated.

serverless.yml:

service: yumyum-layered

provider:
  name: aws
  runtime: nodejs8.10
  region: us-east-1

  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "dynamodb:*"
        - "s3:*"
        - "lambda:*"
        - "cognito:*"
      Resource: "*"

package:
  individually: true

functions:
  masterResolver:
    handler: functions/MasterResolver.handler
    layers:
      - arn:aws:lambda:us-east-1:XXXXXXX:layer:yumyum-coreLibraries:1

I’m also experiencing this issue did you find a solution.

Hi, my colleague had the same issue and updating his Serverless seemed to solve the issue.

The example from that repo you referenced doesn’t look valid. Also I don’t see your layers property in your serverless.yml file.

I’ve got it working with serverless.yml:

layers:
  test:
    path: layer # path of the dir you're expecting to import stuff from.
    name: ${self:provider.stage}-layerName
    description: Description of what the lambda layer does
    compatibleRuntimes:
      - nodejs8.10
    allowedAccounts:
      - ${self:provider.accountId}
    retain: true

and then my lambda function has a property of “layers” as well, like. You can reference the lambda layer by name case sensitive (e.g. Test, not test) appended with “LambdaLayer”:

layers:
  - {Ref: TestLambdaLayer}

Hi, you can consider this plugin, it attaches automatically layers to your lambda.