When ChatGPT was first released, I remember my Twitter timeline being inundated with screenshot after screenshot of AI generated responses. Everything from simple questions to complex programming logic, with most marveling at the technological advancement. The tech was incredibly interesting, for sure, but to me, it quickly became quite tiring. I even contemplated muting the keyword for a bit! It wasn’t because I don’t welcome progress, quite the opposite. I just had this sinking feeling that AI generated text was going to start polluting the Internet. I certainly wasn’t wrong about that, but I think there are other much more concerning angles to this.
I am a HUGE fan of serverless architectures. This new type of compute not only opens up more possibilities for developers, but can support highly-scalable, complex applications for a fraction of the cost compared to provisioning virtual servers. My first question when planning a new application is always, “Can I build this with serverless?” Spoiler alert, the answer is almost always YES!
I’ve been building serverless applications since the release of AWS Lambda in 2015, so answering the question above is pretty easy for me. However, a lot of people I talk to who are new to serverless often have many questions (and misconceptions). I want you to be successful, so below I’ve create a list of 10 things you need to know when building a serverless application. These are things I wish I knew when I started, so hopefully they’ll help you get up to speed a faster and start building some amazing applications.
Since AWS released support for Node v8.10 in Lambda, I was able to refactor Lambda API to use
async/await instead of Bluebird promises. The code is not only much cleaner now, but I was able to remove a lot of unnecessary overhead as well. As part of the refactoring, I decided to use AWS-SDK’s native promise implementation by appending
.promise() to the end of an S3
getObject call. This works perfectly in production and the code is super compact and simple:
let data = await S3.getObject(params).promise()
The issue came with stubbing the call using Sinon.js. With the old promise method, I was using
promisifyAll() to wrap
new AWS.S3() and then stubbing the
getObjectAsync method. If you’re not familiar with stubbing AWS services, read my post: How To: Stub AWS Services in Lambda Functions using Serverless, Sinon.JS and Promises.