【问题标题】:Serverless error - No file matches include / exclude patterns无服务器错误 - 没有文件匹配包含/排除模式
【发布时间】:2021-05-06 03:06:30
【问题描述】:

我正在尝试使用 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

这很好用。现在只要我添加一个图层,我就会收到以下错误

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

我还尝试添加包含和排除模式。但这并没有解决我的问题

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

【问题讨论】:

    标签: serverless aws-serverless serverless-architecture


    【解决方案1】:

    我遇到了同样的问题,找到了这个答案here

    serverless 正在根据根包中指定的模式检查这些文件:exclude 并且因为 ./** 匹配每个文件而 include-pattern./functions/**/* 不匹配,因此实际上没有文件包含在层,从而导致错误。

    只需尝试从排除项中删除 ./**

    package:
      individually: true
      exclude: 
        - ./** # <-- remove this!
    

    【讨论】:

      猜你喜欢
      • 2021-10-23
      • 2021-10-07
      • 2022-09-26
      • 1970-01-01
      • 2021-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-09
      相关资源
      最近更新 更多