Amazon web services 在APIGateway中设置查询字符串和标头的名称

Amazon web services 在APIGateway中设置查询字符串和标头的名称,amazon-web-services,aws-api-gateway,amazon-cloudformation,Amazon Web Services,Aws Api Gateway,Amazon Cloudformation,下面是我如何设置堆栈的示例。我只发布了其中的一部分,请放心,堆栈工作正常 我想问的问题是,如何在url级别指定queryString名称。现在在AWS控制台(Web UI)上,它显示{orderId},但我希望它显示其他内容。我如何修改它 此外,它在AWS UI上显示{orderId}标题框。我也想改变这一点 OrdersPathResource: Type: "AWS::ApiGateway::Resource" Properties: RestApiId:

下面是我如何设置堆栈的示例。我只发布了其中的一部分,请放心,堆栈工作正常

我想问的问题是,如何在url级别指定
queryString
名称。现在在AWS控制台(Web UI)上,它显示
{orderId}
,但我希望它显示其他内容。我如何修改它

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

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"]]

从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"]]