DEV Community

reasonable person
reasonable person

Posted on

Debugging AWS Lambda Functions in GO

I've spent a fair amount of time on the interwebs reading various resources on the topic of debugging AWS Lambda functions locally for testing. There's really not much helpful information out there. Most resources point you to overengineered solutions that involve way more than you need and the final result still leaves something to be desired in most cases.

In the AWS SDK for the Go runtime, Lambda functions support the ability to run as RPC servers, making them very easy to invoke in a multitude of different environments.

So, when we run our Lambda locally, it just serves and blocks like any other server based system. From there, we only need a RPC client to send it a message.

A huge benefit to doing it this way, is that if your Lambda uses any other AWS service clients (i.e DynamoDB, S3, Secrets Manager, etc.), you can actually debug those live deployed cloud based resources without doing anything else. No 3rd party libraries, no frameworks, no containers. The only catch is that you have to have your AWS shared credentials file updated in such a way that the session that the Lambda creates can be authenticated.

Check out the source for the RPC client, it's quite simple, and is just the right amount of engineering to solve the problem.

You're welcome, internet.
https://github.com/JS10X/aws-lambda-rpc-client

Top comments (0)