Aws lambda 无服务器框架Api网关类型错误

Aws lambda 无服务器框架Api网关类型错误,aws-lambda,aws-api-gateway,serverless-framework,Aws Lambda,Aws Api Gateway,Serverless Framework,我有一个无服务器模板,其中包括一个带有API网关的lambda函数。我在模板中包含了一个api密钥。一切都部署得很好,但最后我仍然收到以下类型错误: TypeError:无法读取未定义的属性“apikees” 我真的找不到解决这个问题的好办法。以下是我的无服务器模板示例,其中包括apikeys: plugins: - serverless-add-api-key provider: name: aws timeout: 30 # Because API Gateway runti

我有一个无服务器模板,其中包括一个带有API网关的lambda函数。我在模板中包含了一个api密钥。一切都部署得很好,但最后我仍然收到以下类型错误:

TypeError:无法读取未定义的属性“apikees”

我真的找不到解决这个问题的好办法。以下是我的无服务器模板示例,其中包括apikeys:

plugins:
  - serverless-add-api-key
provider:
  name: aws
  timeout: 30 # Because API Gateway
  runtime: python3.8
  region: us-east-1
  apiGateway:
    apiKeys:
      - MyKey

我在这里遗漏了什么?

我猜您混淆了我们配置api键的方式,包括使用插件和不使用插件。下面是一个不使用插件的serverless.yml

service: serverless-api-key

provider:
  name: aws
  stage: prod
  timeout: 30
  runtime: nodejs12.x
  apiGateway:
    apiKeys:
      - MyKey
functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: /hello
          method: get
sls在下面部署输出-

Service Information
service: serverless-api-key
stage: prod
region: ap-south-1
stack: serverless-api-key-prod
resources: 14
api keys:
  MyKey: Aeeblv4djg2AmlXXXXXXXXXXXXXX2fk9l4iCDRf
endpoints:
  GET - https://xxxxxxxx.execute-api.ap-south-1.amazonaws.com/prod/hello
functions:
  hello: serverless-api-key-prod-hello
layers:
  None
如果你仍然想使用插件,你需要得到正确的语法。您可以使用下面的serverless.yml-

service: serverless-api-key-2

plugins:
  - serverless-add-api-key
custom:
  apiKeys:
    - name: MyKey33

provider:
  name: aws
  stage: prod
  region: ap-south-1
  timeout: 30
  runtime: nodejs12.x
functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: /hello
          method: get

成功了!谢谢你的帮助。