Search code examples
dockerlocalhostdocker-containeraws-sam-cli

What IP for localhost when doing an axios.request if invoking on function with sam local invoke?


I am using aws sam cli and I do sam local invoke functionName. Everything works just fine, but at some point I want to do a request using Axios to my local API running on a django server. The problem is I don't know which IP to do my GET request. I am concern because 127.0.0.1 is not working, obviously I think, and I am pretty sure there would be something else to do there, cause aws sam cli is invoking my function inside a docker container (right?). I am connecting to internet using WI-FI through a hotspot on my cellphone, also I use a OpenVPN (on my computer) to connect using a vpn. So, again, my question,

Which IP/host must use if I want to do a request to my localhost?

PS: If you need any more details or the question isn't clear enough, please, feel free to comment.


Solution

  • Solution was simpler than I thought. I just changed my django server host to the IP my wireless adapter was giving me through DHCP and then, did the request on the lambda function to that IP. Now I can do sam local invoke functionName and do request to my API running in my localhost

    Perhaps there is a more docker solution to it, but this solved my problem.