2

I have implemented node application with AWSServerlessExpress and deployed in Lambda function. but unable to point API Gateway to node routes. every time I'm getting 404 status.

var express = require('express')
, router = express.Router()

router.post('/es', function(request, response){
    response.status(200).send("Lambda is triggered");
    response.end()
})

router.get('/es/csv', function(request, response){
    response.status(200).send("hello");
    response.end()
})

module.exports = router;

How can I point API gateway directly to get Or Post route?

johndoe
  • 4,387
  • 2
  • 25
  • 40
Gopi Raju
  • 219
  • 3
  • 13
  • are you able to invoke the routes direcly (with a test message)? – gusto2 Mar 07 '18 at 21:07
  • If I have root route with get http verb like below able send request. Other routes '/es', '/es/csv' are throwing 404 error. router.get('/', function(request, response){ response.status(200).send("hello"); response.end() }) – Gopi Raju Mar 07 '18 at 23:14
  • As far I know (that may be wrong too) - these routes will not work directly. You can define extra paths in the API manager, specify the lambda (always the root route will be invoked), but in the API manager it is possible to map input extra parameters to the input message. I don't like this so I will try it out myself – gusto2 Mar 08 '18 at 08:14
  • Thanks, gusto2, I checked with ARN links mapping in API Gateway but now I'm facing another invocation issues that might be related to my execution role. – Gopi Raju Mar 09 '18 at 11:19

1 Answers1

2

After gone through the AWS documentation I have found a solution to my question. To forward the request from API Gateway to node routes in lambda we have to create a new proxy ({proxy+})resource in API gateway under this resource create any method(based on your requirement).

enter image description here

I found this answer here: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-create-api-as-simple-proxy

Gopi Raju
  • 219
  • 3
  • 13