Fast AWS Lambda Code Updates And Improved Lambda Logs

This year I’ve started working with Amazon Web Services (AWS) and most notably AWS Lambda. It’s awesome what Amazon is providing here! It’s cheap, easy to start with when using SAM – Serverless Application Model and easy to integrate with other services. But there are also downsides (which were also discussed a lot on HN). Just to name a few: a) logging is a mess, b) debugging is not possible at all or c) CPU power only comes with more memory. Though I can’t change b) and c), I could do something for a). Furthermore it was also a pain for me to update the Lambda code quickly, because I am using CloudFormation. A CloudFormation update takes a lot of time and summed up to 2:30 min for every update in my case – not acceptable for just changing one line of code. Therefore I decided to write some small CLI tools to overcome the logging problem and code updates with AWS Lambda.

Fast AWS Lambda Code Updates


This tool helps you to update only the code of one or more Lambdas from a CloudFormation stack. In order to use it correctly, you first need to deploy your stack for at least one time. Then, if you just change a few lines of code (and have no changes in your CloudFormation template), you can use the tool. Example for NodeJS:

This also works for JAR files. You just hand over the path to your CloudFormation template, the target file which contains your Lambda code and the stack name. The tool automatically retrieves from the stack which Lambda functions apply for an update and updates them.

For my use case the update time has been reduced from 2:30 min to 10-15 seconds for NodeJS and 50-60 seconds for Java JAR files. A big issue is here that the file size plays an important role, but nevertheless I was able to cut the update time by more than the half. Of course, in case something changes in the CloudFormation template I still have to use a regular stack update.

Improved AWS Lambda Logs


AWS Lambda always stores your log outputs to CloudWatch logs. This is nice, because the use of CloudWatch is free. But it’s also a little bit cumbersome to use. You always have to select your Lambda log group and then the appropriate log stream. For example, it’s not possible to trace a request over multiple Lambdas which can make life easier if you have a larger stack. Therefore I’ve decided to write my own small tool, especially to view such logs over multiple Lambda functions. You can use it like this:

It’s working similar to the Lambda updater tool above: it search the CloudFormation stack for Lambda functions, collects the physical names of them, builds the appropriate Lambda log group name and searches all log groups using a CloudWatch filter pattern. There are far more options to customize the output of the search, so please check out the Github page.

You might ask yourself “How do you know the log group name of a Lambda?” Well, it’s always like this: “/aws/lambda/PHYSICAL_RESOURCE_NAME“. So, if you have the resource name, it’s easy to do the rest.


Tell me what you think of the tools! I’d love to hear your feedback 🙂 Also consider 5 Things To Consider For Writing A Lambda Function if you’re into AWS Lambda development.