1

I am having a use case where I need to invoke a Rest API which is deployed/running on my local-machine (locahost:8090) from an AWS Lambda Function which will get triggered on an SQS event.

I cannot go with API Gateway Option. I am able to invoke the same API using the IP address from POSTMAN, can I use some Rest Client Like HttpClient or RestTemplate to invoke the same API using the IP address.

Also do I need to have some policy attached to my Lambda function, as when I am calling using HttpClient my Lambda function timesout.

2
  • So, just to understand. From a lambda function, you want to make a call to your local REST API hosted on your machine? Yes, postman will work this it is run on your pc. In order for lambda to call your REST API, you need to expose your machine to the internet via your router. I don't think you want to go down that path. Why don't you host your REST API on EC2? Something that lambda can actually reach. Commented Nov 8, 2022 at 15:05
  • EC2 option is available but for that I need to patch my dev branch which I dont want, local branch is having some unwanted commits which may break dev so I wanted to test this on local api instead but looks like it is tricky. How abou trunning the lambda on local uaing SAM Cli?? Commented Nov 8, 2022 at 15:28

1 Answer 1

2

It sounds like what you need is an internet facing proxy that can forward (tunnel) requests to your local machine. Products like ngrok or localxpose are designed to do this easily, giving you an auto-generated host name that is accessible from anywhere on the internet and will forward the http requests to a process running on your local machine.

There are also a number of open source projects with similar functionality, but you would have to host these yourself. Here is an example of an "awesome" repo listing quite a few open source options.

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

2 Comments

Thanks for the response Mike, I am looking into the suggestion you gave.
I think this is the best resolution to my problem, although I would take the suggestion from Mike and host my API in an EC2 instance to get my job done.

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.