AWS Lamba Debugging - How to connect to an API on your local(host) machine
One of my recent bald-patch inducing struggles was to develop and test an AWS Lambda function that connects to a REST API to do some stuff. It is rather nice that you can deploy (using a local Docker container) and debug the said Lambda code in VSCode using the AWS Toolkit extension. In my case, the Lambda attempts to open a connection to a Django REST API which I had running in debug mode on my local machine (i.e. localhost interface). Seems fairly straightforward. If you haven't previously, you'll probably soon run into the issue of opening an API connection to "localhost" from the Lambda code which doesn't work, since in the container context, that's the container's local connection, not the host's. So you need to point the API connection at host.docker.internal instead which is already mapped to your physical machine by Docker. This works like a charm if you are doing straight forward things - like not using prefixes on your domain name. In my c...