I am trying some skeleton deployment using python. Here is my serverless.yaml
My folder structure is
serverless-test
|_lambdas
|____handler.py
|_layers
|____common
|_________somefunction.py
service: serverless-test
frameworkVersion: '2'
provider:
name: aws
runtime: python3.8
lambdaHashingVersion: 20201221
stage: test
region: us-west-2
functions:
hello:
handler: lambdas/handler.hello
This works fine. Now as soon as I add a layer, I get the following error
No file matches include / exclude patterns
service: serverless-test
frameworkVersion: '2'
provider:
name: aws
runtime: python3.8
lambdaHashingVersion: 20201221
stage: test
region: us-west-2
functions:
hello:
handler: lambdas/handler.hello
layers:
- {Ref: CommonLambdaLayer}
layers:
common:
path: layers/common
name: common-module
description: common set of functions
I also tried adding include and exclude patterns. But it didn't solve my problem
service: serverless-test
frameworkVersion: '2'
provider:
name: aws
runtime: python3.8
lambdaHashingVersion: 20201221
stage: test
region: us-west-2
package:
individually: true
exclude:
- ./**
include:
- ./lambdas/**
functions:
hello:
handler: lambdas/handler.hello
layers:
- {Ref: CommonLambdaLayer}
layers:
common:
path: layers/common
name: common-module
description: common set of functions
package:
include:
- ./**
I also tried being very specific
service: serverless-test
frameworkVersion: '2'
provider:
name: aws
runtime: python3.8
lambdaHashingVersion: 20201221
stage: test
region: us-west-2
package:
individually: true
exclude:
- ./**
functions:
hello:
handler: lambdas/handler.hello
layers:
- {Ref: CommonLambdaLayer}
package:
exclude:
- ./**
include:
- ./lambdas/handler.py
layers:
common:
path: layers/common
name: common-module
description: common set of functions
package:
exclude:
- ./**
include:
- ./layers/common/somefunction.py
I had the same issue and found this answer here:
serverless is checking those files against the patterns specified in the root package:exclude and because./** matches every file and the include-pattern./functions/**/* matches none, no files are actually included in the layer, which causes the error.
Just try removing the ./**
from the excludes:
package:
individually: true
exclude:
- ./** # <-- remove this!