0

这里是我如何设置我的堆栈的示例。我只发布这一点,放心,堆栈工作正常。在APIGateway中设置查询字符串和标题的名称

问题我想问一下,我怎么能具体queryString名称在url级别。现在在AWS控制台(Web UI)上,它显示{orderId},但我希望它显示其他内容。我如何修改它?

此外,它在AWS UI上显示{orderId}HEADERS框。我也想改变这一点。

OrdersPathResource: 
    Type: "AWS::ApiGateway::Resource" 
    Properties: 
     RestApiId: 
      Ref: "XYZApi" 
     ParentId: !GetAtt [XYZApi, RootResourceId] 
     PathPart: "orders" 

OrdersIdPathResource: 
    Type: AWS::ApiGateway::Resource 
    Properties: 
     RestApiId: 
      Ref: "XYZApi" 
     ParentId: 
      Ref: "OrdersPathResource" 
     PathPart: "{ordersId}" 

StatusPathResource: 
    Type: AWS::ApiGateway::Resource 
    Properties: 
     RestApiId: 
      Ref: "XYZApi" 
     ParentId: 
      Ref: "OrdersIdPathResource" 
     PathPart: "status" 

GetOrdersShipmentStatusMethod: 
    Type: "AWS::ApiGateway::Method" 
    Properties: 
     ApiKeyRequired: true 
     AuthorizationType: "AWS_IAM" 
     HttpMethod: "GET" 
     ResourceId: 
      Ref: "StatusPathResource" 
     RestApiId: 
      Ref: "XYZApi" 
     Integration: 
      Type: "AWS_PROXY" 
      IntegrationHttpMethod: "POST" 
      Uri: !Join ["", ["arn:aws:apigateway:", !Ref "AWS::Region", ":lambda:path/2015-03-31/functions/",!GetAtt GetOrdersShipmentStatusLambdaFunction.Arn, "/invocations"]] 

回答

0

从您的CloudFormation模板片断,您使用Lambda代理集成,因此API网关不会让你设置的参数映射到你的整合。但是如果你想在方法方面有请求参数,你可以改变你的方法,如

GetOrdersShipmentStatusMethod: 
    Type: "AWS::ApiGateway::Method" 
    Properties: 
     ApiKeyRequired: true 
     AuthorizationType: "AWS_IAM" 
     HttpMethod: "GET" 
     ResourceId: 
      Ref: "StatusPathResource" 
     RestApiId: 
      Ref: "XYZApi" 
     RequestParameters: 
      method.request.header.headerName: false 
      method.request.querystring.querystringName: false 
     Integration: 
      Type: "AWS_PROXY" 
      IntegrationHttpMethod: "POST" 
      Uri: !Join ["", ["arn:aws:apigateway:", !Ref "AWS::Region", ":lambda:path/2015-03-31/functions/",!GetAtt GetOrdersShipmentStatusLambdaFunction.Arn, "/invocations"]] 
相关问题