0

I have an ExpressJS project with several routes

var app = new express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.static(path.join(__dirname, 'public')));
app.use('/car', car);
app.use('/bike', bike);
app.use('/bus', bus);
app.use('/train', train);
app.get('/',function(req,res){
  res.render('layout', { title: 'app example' });
});
module.exports = app

I have deployed with ClaudiaJS to AWS Lambda and the deployment seems to work.

After that, I am configuring AWS API Gateway to invoke different resource paths in the Lambda Function. What I have found is that it properly works for the root path '/' but when I try to invoke a different resource path from API Gateway I get this error in API Gateway:

"You do not have permission to perform this action"

Additionally I get this message in the Lambda Function:

"The API with ID XXXXXXXXX does not include a resource with path /car having an integration arn:aws:lambda:myzone:XXXXXXXXXXXXX:function:functioname on the GET method."

Is this something possible to do currently with ClaudiaJS or even a supported configuration (multiple resource paths) in Lambda functions? Any experience?


Update 1: this seems to be possible for AWS Lambdas. See here: Is it possible to connect API gateway with node routes in AWS lambda? Not sure if ClaudiaJS can manage this use case


Update 2: ClaudiaJS confirms in their support group https://gitter.im/claudiajs/claudia that deploying a multi-route ExpressJS app to a single AWS Lambda is possible with their product and refers me to https://livebook.manning.com/#!/book/serverless-apps-with-node-and-claudiajs/chapter-13/v-5/167 So it looks some config/invokation error on my side


Update 3: Managed to invoke successfully 2 routes:

app.get('/test', function (req, res) {
    res.send('Hello World test!');
});
app.get('/', function (req, res) {
    res.send('Hello World!');
});

Getting {"message": "Internal server error"} for third route accessing MongoDB on EC2. Looks a permission issue.

pellyadolfo
  • 981
  • 10
  • 23
  • how do you call the AWS Api gateway with specific routes ? Using curl is easy since you just call the URL, but what about using the amazon SDK ? With: $result = $client->invoke(array( 'FunctionName' => 'Express-Lambda-Boilerplate', 'InvocationType' => 'RequestResponse', )); Do you know how can I add the path in here ? – Scobee Jun 06 '19 at 21:28

1 Answers1

0

Finally, this issue had nothing to do with ClaudiaJS.

It just needed to use the internal IP of the EC2, instead the external one, as described here Invalid permission from Lambda to MongoDB in EC2

pellyadolfo
  • 981
  • 10
  • 23