Instructor: 0:00 We have a Lambda function with an API gateway attached to it. I can call this function by going to this API endpoint. What we would like to do is to run this code in our Lambda function.
0:09 The problem is this code is using an external dependency. I cannot just go ahead and paste this into the AWS console, because it won't work. We need to be able to provide axios as a dependency to our Lambda function.
0:22 In order to do that, we have to use Lambda function packages. In AWS Lambda, not only we can edit the code in this editor, but we can also upload a zip file containing our code as well as all the dependencies. To create a Lambda function package, we have to zip both the index.js as well as node modules.
0:38 In order to do that, I'm going to use the zip command, but you can use whatever you want in order to create a zip file. What matter is that we have to include all the code and dependencies inside. I'm going to create this new zip file called lambda_package. Now, let's go ahead and upload it to AWS. Click over here, upload the package, and click save.
0:56 Now we can see the code that we've just uploaded in this editor over here. There are also all those node modules, including axios, that we are using in order to get a random cat fact. Now if I go over here to our API, and refresh it, I'm going to get a random cat fact.