0

Using the console, I was able to configure an API gateway method to pass HTTP requests with a path parameter off to a another URI.

The result looks as follows enter image description here

This would make it so that my request is forwarded to https://example.com with the same (greedy) path parameter.

Though this was successful enough, I need to be able to be able to specify this as an AWS::Serverless::Api resource in a cloudformation template. As far as I can tell, the documentation for the Serverless Application Model does not provide any mention as to how to accomplish this.

Can it be done on a serverless resource, or do I need to work with traditional AWS::ApiGateway::Resource/Method's?

JSON Brody
  • 736
  • 1
  • 4
  • 23

1 Answers1

0

Easiest way I found is to create a swagger definition using DefinitionBody, here is an example, so you can get an idea. Repo

IMPORTANT: if you use the proxy integration on Lambda, httpMethod method in the x-amazon-apigateway-integration should be POST regardless your method GET, PUT, POST or DELETE => httpMethod: POST

DefinitionBody: 
    swagger: 2.0
    info:
      title: EventSource API Definition
    paths:
      /events/{id}:
        get:
          summary: Get an event details
          description: Retrieve specific event
          parameters:
          - name: id
            in: path
            required: true
            type: string
          consumes:
            - application/json
          produces:
            - application/json
          x-amazon-apigateway-integration:
            uri:                  
              Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetEventsFunction.Arn}/invocations
            responses: {}
            httpMethod: POST
            type: aws_proxy
Ntwobike
  • 2,406
  • 1
  • 21
  • 27