我正在尝试使用Python进行一些骨架部署。这是我的serverless.yaml文件。
我的文件夹结构如下:
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
这个工作正常运行。现在当我添加一个层时,就会出现以下错误:
没有文件与包括/排除模式相匹配
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
我也尝试添加包含和排除模式。但是这并没有解决我的问题。
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:
- ./**
我也尝试过非常具体的方式
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
./**
改成了./*
。现在它可以工作了。 - Alex Montoya