AWS API Gateway Method request path parameter not working

后端 未结 1 539
南旧
南旧 2021-01-23 21:49

I am trying to configure API Gateway to route requests to a specific route on my backend GO microservice. I am using a GET request method with a VPC_LINK

相关标签:
1条回答
  • 2021-01-23 22:16

    Your post looks suspiciously like this

    If you are convinced it's not the things mentioned in that response, then I would check the routing in your integration request.

    The URI of your curl request is /v1/nmapscan/ which means API Gateway will look at STAGE v1, resource /nmapscan. Once that occurs, API GW sends the request to the VPC Link based on the uri configured in the Integration Request. I'm not super familiar with Terraform, but it looks like you are sending it to:

    http://aws_lb.myapis.dns_name:8000

    I also see that you have "request parameters" defined in terraform(but maybe commented out?):

    
        //  request_parameters = {
        //    "integration.request.path.nmapscan" = "method.request.path.nmapscan"
        //  }
    
    

    I would check that after deployment, the Integration Request in the API GW Console shows that this is being routed to the proper route. Without knowing for sure, I'm assuming your application path is actually http://aws_lb.myapis.dns_name/nmapscan:8000 and that's not being passed correctly to the NLB because it isn't properly mapping for some reason in the Integration Request.

    All of that being said, the easiest way to see what the URI is when the request is being sent to the NLB is to enable API Gateway execution logs, and enable full request/response data on those logs. It will give you something similar to this:

    
        (32e76dc1-2e80-11e9-b849-1d4cbf2f1403) Endpoint request body after transformations: {"resource":"/testproxy","path":"/testproxy","httpMethod":"GET","headers":[TRUNCATED]
        (32e76dc1-2e80-11e9-b849-1d4cbf2f1403) Sending request to [TRUNCATED]
    
    

    I truncated for brevity but you can see the path definition there. It will be useful to look at that to narrow down where the error is originating.

    0 讨论(0)
提交回复
热议问题