首页 文章

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

提问于
浏览
6

我想为我的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

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

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

资源:资源:

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

1 回答

相关问题