I am trying to integrate lambda in API gateway with VPC end point via aws lambda.
https://aws.amazon.com/blogs/compute/using-api-gateway-with-vpc-endpoints-via-aws-lambda/
My problem is that my i have six different type of webservices places in vpc. So trying to call them with lambda function and get back the result. So i follow the instruction as per above link. but i am stuck at a place. In lambda function
var options = {
host: event.requestParams.hostname,
port: event.requestParams.port,
path: event.requestParams.path,
method: event.requestParams.method
};
if i provide all the values statically then my request is passed to the my webservice in VPC. which is ok. So then i try to use api gate to do the same with dynamic values, where i put ip and host statically in template as per below.
#set($allParams = $input.params())
{
"requestParams" : {
"hostname" : "XXX.XXX.XX.XX",
"port" : "XX",
"path" : "$context.resourcePath",
"method" : "$context.httpMethod"
}
So i made request from postman to this api request is reaching the lambda function. My question is how i will pass the path to my webservice to this lambda function. I have used template and lambda as per the link above. So when i put call to the webservice, please let me know how i will pass webservice url. currently it is trying to call the resource path which is defined in api gateway eg. /testgateway which is ofcourse will show 404 error. while web service path will look like
eg. http://host/webserviceType/webservice.
I feel i am doing some silly mistake.
Please suggest as i am new to aws.
Thanks Gurvinder
I have solved the issue as in aws payment gateway we have to attach template with every API url. So in template instead of "$context.resourcePath" i have used the path of the webservice which solves the issue.