7

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.

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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:

1 Comment

perfect hint! this is poorly documented. coming from cdk with Invalid mapping expression specified: integration.request.path.proxy, Invalid mapping expression specified: method.request.path.proxy] here you find the correct order of the parameters. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.