Lambda Local Environments are Complicated

Lambda is a great new way of creating functions hosted on AWS which get called on specific events. They are incredibly scalable as well as inexpensive because you are only charged for the time the function is running. The past couple weeks, since Lambda added support for Golang I have been digging into how it works and ways to use it. I am currently writing my new blog backend using Lambda and Golang and am dealing will all the expected issues when using a new technology.

Local Development

Most of the issues I am seeing with Lambda development are coming from local development. Once the function is hosted on AWS I rarely run into issues but getting the code to run locally initially, and debugging it has been incredibly tricky. I will highlight some of the main issues I have run into here and hopefully will make a follow-up blog post with fixes for them.

Local Resources

This is the most annoying issue I've come across. For the life of me, I haven't found a way to connect to a local database, service, or cache. Whether that is locally on my machine or in a separate Docker container. I KNOW there is a way, there is a vague reference to in the AWS Local Sam documentation but no actual uses or examples of it being done.

YAML Files

More of a complaint then an issue, but to run SAM locally, you need a template.yaml file to create events. But with the serverless framework I am using, Serverless, you need a serverless.yaml file. This is not a huge problem but as the amount of functions increases keeping both files up to date can become a challenge, and forgetting to update one or the other can lead to problems in development or production.

It would really be nice if one YAML file could be used for both development and production. Now maybe that is possible, but it is something I haven't found yet, and I have looked around quite a bit.

POST Body Size

The most frustrating problem I've come across so far is the POST body size issue. What happens is in development if you send up a file in the POST body, and it is larger than 128KB, you receive the error:

standard_init_linux.go:185: exec user process caused "argument list too long"

This is really trying to say the image is too large. Apparently, in production, this is not an issue, but you cannot expect developers to build code and not be able to test a feature as basic as sending a file to an API endpoint... If Amazon expects people to use Lambda for their APIs, they need to sort things like this out.


So far I am loving Lambda. There are so many exciting uses I can see for it. Building my blog with it is showing me lots of the good Lambda has to offer, but it is a relatively new technology, and there are lots of improvements I expect to see soon. I hope some of these issues I brought up get addressed, or if there is a fix, the documentation and troubleshooting become clearer so fixes can be reasonably found.

Author image

About Ryan McCue

Hi, my name is Ryan! I am a Software Developer with experience in many web frameworks and libraries including NodeJS, Django, Golang, and Laravel.