In this video, learn how to build a very simple Lambda in the AWS console using Node.js.
Having a mismatch here can be the source of very annoying bugs. Click the orange create a function button. On the blueprint page click the author from scratch button. Now let's give our Lambda a name, we'll call it LambdaTest. Choose create a custom role. The browser will open a new tab for us to choose our role. For IAM select create a new IAM role.
The role name should be lambda_basic_execution, click the allow button. We should return to the Lambda page with the existing role now set to lambda_basic_execution, click the create function button. Take a look at the basic settings options. The default values are 128 MB of memory and a time-out of 3 seconds.
The memory indicates the absolute maximum amount of memory your Lambda can use. Any more will trigger an out of memory exception. Keep in mind that your CPU's power is proportional to the amount of memory allocated. If your application uses more than the allotted time, Lambda terminates it. Should that happen there are two things that you can do. First, you can lengthen the time-out and second you can increase the memory which will increase the CPU speed and hopefully decrease the execution time.
Let's take a look at editing code in the AWS console. Under code entry type it should be set to edit code inline. Set the run time to the highest version of Node available. Currently only Node and Python programs are online editable. Verify that the handler is index.handler. Now let's look at some sample code. Your Lambda function receives three parameters. Event, context and callback.
If there is an issue, the first parameter returned is the error. If there were no problems, we set it to null and the second parameter is whatever data we'd like to send.
- Creating an AWS Lambda account
- Creating a simple Lambda function in Node.js
- Testing the Lambda function
- Creating Kotlin apps with Spark, IntelliJ IDEA, Maven, and the AWS library
- Binding the API gateway to your Lambda function
- Adding data with MongoDB
- Developing and debugging your Lambda function locally