I wrote about AWS CodeStar in my previous post. I was impressed by what it can provide developers. With just a few clicks, you get a fully functional API running in a serverless hosting environment (AWS Lambda), and you get a full build/deploy pipeline to boot.

But how can you add another API endpoint after you stand up a project?

If you use the Node.js/Express.js template, you ultimately have an Express site running. Adding another endpoint to that is easy. We just need to add another handler.

Initially, we had two handlers: one for GET and one for POST.

We can easily add a new bye method by just adding another event handler.

But that only gets us a Lambda that works if we run this as an Express project. But what about making it run and deploy it as an AWS Lambda?

We need to update the template.yml file with another resource. This allows you to test it locally with the same CLI, but more importantly, the next time you check in your code, the new API method will be pushed to your environment in the cloud.

Share This