dege
dege

Reputation: 2949

API Gateway configure http integration with input passthrough serverless 1.x

Is there a way to map all parameters,headers and body to the other http endpoint? does it require a special template?

This is what I've got so far:

functions:
  myfunction:
    handler: lambda.myfunction # dummy hanlder
    events:    
      - http:
          path: resource/{resourceId}/other
          method: get
          integration: HTTP
          request:
            uri: http://url/resource/{resourceId}/other
            parameters:
              'method.request.path.resourceId': true
              'method.request.header.my-header': true
          response:
            statusCodes:
              200:
                pattern: ''

Whenever i create directly in the console the the passthrough option is enabled by default and it maps the resourceId correctly.

I tried to look into the documentation but seems that there's almost no documentation on the http integration, unless i'm missing something.

Upvotes: 0

Views: 734

Answers (2)

jackko
jackko

Reputation: 7344

Is there a way to map all parameters,headers and body to the other http endpoint? does it require a special template?

Yes, use HTTP_PROXY integration type. In the console this is a checkbox in the Integration Request page.

Upvotes: 1

dege
dege

Reputation: 2949

I was able to find a workaround to have this working, seems more a workaround than the correct solution.

I had to set the Integration.RequestParameters in the resources of the serverless.yml to achieve this.

resources:
  Resources:
   ApiGatewayMethodV1ResourceResourceidVarOtherGet:
    Properties:
      RequestParameters:
        method.request.path.resourceId: true
        method.request.header.my-header: true
      Integration:
        RequestParameters:
          integration.request.path.resourceId: method.request.path.resourceId
          integration.request.header.my-header: method.request.header.my-header

Upvotes: 0

Related Questions