AWS CloudFormation API GatewayV2 路由创建

Mah*_*man 5 amazon-web-services aws-cloudformation aws-api-gateway

我正在创建一个模板来创建一个带有apigatewayv2.

我在模板中的 API 定义是:

sfHttpApi:
    Type: AWS::ApiGatewayV2::Api
    DependsOn: sfLambdaFunction
    Properties:
      Name: !Sub sfHttpAPI-${Region}-${Env}
      ProtocolType: HTTP
      Target: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${sfLambdaFunction}/invocations
      CredentialsArn: !GetAtt sfApiGatewayRole.Arn

  sfApiTriggerLambdaPermission:
    Type: "AWS::Lambda::Permission"
    Properties:
      Action: lambda:InvokeFunction
      FunctionName: !GetAtt sfLambdaFunction.Arn
      Principal: apigateway.amazonaws.com
      SourceArn: !Sub 'arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${sfHttpApi}/' 

  sfApiLambdProxyIntegration:
    Type: "AWS::ApiGatewayV2::Integration"
    Properties:
      Description: Lambda Integration
      ConnectionType: INTERNET
      IntegrationMethod: POST
      IntegrationUri: !Sub  "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${sfLambdaFunction.Arn}/invocations"
      PayloadFormatVersion: '1.0'
      ApiId: !Ref sfHttpApi
      IntegrationType: AWS_PROXY

  sfRoute:
    Type: 'AWS::ApiGatewayV2::Route'
    DependsOn:
      - sfApiLambdProxyIntegration
    Properties:
      ApiId: !Ref sfHttpApi
      RouteKey: 'POST/'  **??? This is the part I dont know how to set**
      AuthorizationType: NONE
      Target: !Join 
        - /
        - - integrations
          - !Ref sfApiLambdProxyIntegration
Run Code Online (Sandbox Code Playgroud)

我尝试以不同的方式在路由定义中设置路由键,但在创建堆栈时出错:

提供的路由密钥的格式不适合 HTTP 协议。格式应为“/”或“$default”(服务:AmazonApiGatewayV2;状态代码:400;错误代码:BadRequestException;请求 ID:53198c85-fc41-4c76-89c4-7d2db7a7a5b6)

如何设置路由键?

Mar*_*ari 4

后面加一个空格POST,即POST /