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?

4
  • are you able to invoke the routes direcly (with a test message)? Commented Mar 7, 2018 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() }) Commented Mar 7, 2018 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 Commented Mar 8, 2018 at 8: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. Commented Mar 9, 2018 at 11:19

1 Answer 1

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

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

2 Comments

how are you calling this endpoing ? Are you using the Amazon SDK and doing ->invoke, or just a plain curl ?
I'm just invoking from some other front end frameworks @Scobee

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.