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"]] 
相關問題