Amazon cloudformation 在API GatewayV2阶段使用云形成启用CloudWatch日志

Amazon cloudformation 在API GatewayV2阶段使用云形成启用CloudWatch日志,amazon-cloudformation,aws-api-gateway,amazon-cloudwatchlogs,Amazon Cloudformation,Aws Api Gateway,Amazon Cloudwatchlogs,有一个,但它没有使用AWS::ApiGatewayV2::Stage,我需要只有V2提供的AutoDeploy 如何在AWS API网关中使用CloudFormation启用CloudWatch日志并记录完整的消息数据(如图所示) 我在这个阶段的文档中找不到任何东西 我使用的是自动部署的阶段。我可以创建日志组,IAM角色可以在CloudWatch中编写日志,但我无法启用日志本身 wsApiGateway: Type: AWS::ApiGatewayV2::Api Properties

有一个,但它没有使用AWS::ApiGatewayV2::Stage,我需要只有V2提供的
AutoDeploy

如何在AWS API网关中使用CloudFormation启用CloudWatch日志并记录完整的消息数据(如图所示)

我在这个阶段的文档中找不到任何东西

我使用的是自动部署的阶段。我可以创建日志组,IAM角色可以在CloudWatch中编写日志,但我无法启用日志本身

wsApiGateway:
  Type: AWS::ApiGatewayV2::Api
  Properties:
    Name: foo-ws-gateway
    Description: Api Gateway for Websockets
    ProtocolType: WEBSOCKET
    RouteSelectionExpression: $request.body.action
    DisableExecuteApiEndpoint: true # I use custom domain

# routes and integrations ommitted.

wsApiStage:
  Type: AWS::ApiGatewayV2::Stage
  DependsOn:
    - wsConnectRoute
    - wsSendRoute
    - wsDisconnectRoute
  Properties:
    StageName: production
    Description: Autodeploy in production
    AutoDeploy: true
    ApiId: !Ref wsApiGateway
    AccessLogSettings:
      DestinationArn: !GetAtt wsApiGatewayLogGroup.Arn
      Format: '{"requestTime":"$context.requestTime","requestId":"$context.requestId","httpMethod":"$context.httpMethod","path":"$context.path","routeKey":"$context.routeKey","status":$context.status,"responseLatency":$context.responseLatency, "responseLength":$context.responseLength, "integrationError":$context.integration.error}'

我还必须转到ApiGateway以前的版本来定义帐户,以便我可以指定IAM角色ARN,该角色对帐户中的CloudWatch日志具有写访问权限(控制台的API网关中的设置部分)。它似乎没有AWS::ApiGateway2::帐户

apiGatewayAccountConfig:
  Type: "AWS::ApiGateway::Account"
  Properties:
    CloudWatchRoleArn: !GetAtt apiGatewayWatchLogsRole.Arn
如何在AWS API网关中使用CloudFormation启用CloudWatch日志并记录完整的消息数据(如图所示)

你不能HTTP API(即ApiGatewayV2)不支持执行日志,如AWS所述:

HTTP API目前仅支持访问日志记录,这些API的日志记录设置不同。有关更多信息,请参阅为HTTP API配置日志记录