如何通过云形成模板(serverless.yml)启用api网关日志?

Nag*_*ama 7 lambda aws-cloudformation aws-lambda aws-api-gateway serverless-framework

我想为我的api网关启用api网关日志,这是我的lambda函数的环绕.

service: myservice

provider:
  name: aws
  runtime: python3.6
  stage: ${opt:stage}
  region: ${self:custom.AwsRegion}
  timeout: 130
  memorySize: 128


functions:
  create_user:
    handler: functions/create_user.lambda_handler

    events:
      - http:
          path: /create_user
          method: post
          authorizer: aws_iam
          private: true
Run Code Online (Sandbox Code Playgroud)

当我部署它时,我确实看到云计算中的lambda日志.但是API网关日志没有在cloudwatch中重新编码.任何人都可以启发我的云形成语法,为我的api门方式启用日志吗?

我尝试添加下面的代码,但看起来它正在尝试创建新的api端点.

资源:资源:

ApiGatewayStage:
  Type: AWS::ApiGateway::Stage
  Properties:
    RestApiId:
        Ref: ApiGatewayRestApi
    StageName: ${opt:stage}
    MethodSettings:
      - DataTraceEnabled: true
        HttpMethod: "*"
        LoggingLevel: INFO
        ResourcePath: "/*"
        MetricsEnabled: true
Run Code Online (Sandbox Code Playgroud)

Kan*_*yan 2

您可以通过外部插件来完成此操作,此处详细讨论了解决方案。

https://github.com/serverless/serverless/issues/1918