From the course: Complete Guide to Serverless Web App Development on AWS

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Solution: Add and test a function with API to your project

Solution: Add and test a function with API to your project - Amazon Web Services (AWS) Tutorial

From the course: Complete Guide to Serverless Web App Development on AWS

Solution: Add and test a function with API to your project

(upbeat music) - [Instructor] Let's see how I solve this challenge. First, go to your stack, hello-cdk-stack. And here we can add a new function. Let's minimize this and this, and let's put it under the API gateway that we have defined. So I will write a new function, something like this. The new Lambda function. I'm the most original person with naming. I use the same constructor and I put a new name to it. Entry path is this file, new.ts in the functions directory, We'll create this file in a second. Handler handler and then the runtime, node 20. The bundle configuration is the same that we have done before. Next, I'm going to attach the API gateway to this function. And now we have all the constructs ready. Let's go to our functions directory and create a new file called new.ts. And in here, I will write again a very similar function that doesn't do much. Hello, this is your new Lambda responding, similar thing that we have before. Now you are ready to move on and deploy. So let's…

Contents