Welp, we're going to look at some nodejs code for and aws lambda function here, and specifically the code will be invoking a different lambda function. Although there are a few ways to do this, I really wanted to find a way of chaining lambdas such that they don't have to wait for the one one they just called to finish. It's a bit confusing, but maybe with some example you'll understand what I mean. Well then let's dive right in!
Using AWS CodeStar is really awesome, and I highly recommend it. However, you need to be careful to modify your initial template.yml file appropriately or you'll have random HelloWorlds popping up all over the place. This blog post is about how to modify the template.
Once upon a time I was the serverless guy at a startup company building lambda functions. My function went into production at 128mb of memory and a timeout of 3 seconds. Because of game had "live races" we would see big spikes in traffic at certain times of the day, and unfortunately I would also see big spikes in the number of errors in the CloudWatch metrics charts... My boss even opened the website during the high volume event and noticed requests to the lambda returning 400 error. In the cloudwatch logs I could norrow down the logs to just the high volume time and see many timeout errors happening during this period. Needless to say, this is not a good look, and you don't want it to happen to you (especially you, future Jim)!
This is something I got wrong went I scaffolded out my first CodeStar AWS Lambda pipeline and went to add new environments. To make your project work with AWS CodeStar and CodePipeline you basically need a buildspec.yml and a template.yml file in the root of your project, but that's really it. Then when you connect your source code repository to CodePipeline it will look for these files (or whatever names you have configured for them in the AWS Codepipeline settings) to build and deploy your project.
Things like this are what make it difficult to argue that AWS isn't still the leader in serverless. When we say, "a Lambda function" then sure, we could just expose one function. With the nodejs package aws-serverless-express you can easily handle lots of different endpoints that may or may not have query parameters as well. To me this makes my lambda functions a lot more logically organized as routes.
The posts on this site are written and maintained by Jim Lynch. About Jim...