Flynn81
Flynn81

Reputation: 4178

Path parameters ignored by AWS API Gateway using proxy+

I have a REST API on the AWS API Gateway. It has one resource, /{proxy+}, that is configured with the ANY method. The integration request is setup to be a VPC_PROXY, meaning its using a VPC Link. The VPC link is to a network load balancer that is fronting an app I have running on an ECS cluster using Fargate.

When using the console's option to test the API, I can confirm that requests are reaching my app but the resource being requested is always / according to my logging. If I attempt to set the {proxy} value in the method test screen on the console, it seems like my app only ever gets requests for /. If I set {proxy} to something like widget/5, the response I receive is as if I was request /.

I'm wondering if there is some way to troubleshoot this, scouring the AWS documentation I can't figure out where I'm going wrong with my setup.

Upvotes: 7

Views: 3852

Answers (2)

DiviNik
DiviNik

Reputation: 161

What works for me is by adding the following properties:

Resources:
  APIGWProxyMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      RequestParameters: 
        method.request.path.proxy: true # enable proxy
      Integration:
        RequestParameters:
          integration.request.path.proxy: method.request.path.proxy # map method proxy param to integration proxy param
      ... # the rest of integration property
    ... # other properties

Articles that helped:

Upvotes: 3

Kaustubh Khavnekar
Kaustubh Khavnekar

Reputation: 2923

In your integration, the endpoint URL should be http://loadbalancerurl/{proxy}. I couldn't find any documentation specifically for VPC Link integration, but there is a tutorial for HTTP proxy integration which has similar steps.

If you are using openapi spec, the integration section would look something like this:

x-amazon-apigateway-integration:
  uri: "http://loadbalancerurl/{proxy}"
  responses:
    default:
      statusCode: "200"
  requestParameters:
    integration.request.path.proxy: "method.request.path.proxy"
  passthroughBehavior: "when_no_match"
  connectionType: "VPC_LINK"
  connectionId: "your-vpclink-id"
  httpMethod: "ANY"
  type: "http_proxy"

When using the console, integration.request.path.proxy: "method.request.path.proxy" mapping was added automatically when I added {proxy} to my endpoint URL.

Upvotes: 5

Related Questions