Lambda Functions with Node.js

Riyaz Sayyad | AWS Certified Database Specialist
A free video tutorial from Riyaz Sayyad | AWS Certified Database Specialist
Best Selling Instructor, Tech Evangelist at Rizmax Software
4.5 instructor rating • 3 courses • 28,755 students

Learn more from the full course

AWS Lambda & Serverless Architecture Bootcamp (Build 5 Apps)

AWS Serverless with AWS Lambda, API Gateway, Amazon DynamoDB, Step Functions, SAM, the Serverless Framework, CICD & more

25:23:00 of on-demand video • Updated December 2019

  • Master AWS Lambda, API Gateway, DynamoDB, and Step Functions from the ground up (Full of Demos and Hands On)
  • Streamline your development and deployment with AWS SAM as well as the Serverless Framework
  • Automate serverless deployment with AWS CI/CD tools like CodeCommit, CodeBuild and CodePipeline
  • Build Serverless REST API, Web App, Android and iOS Mobile Apps, Alexa Skill, IoT App and more
  • Integrate different services like S3, Kinesis, SNS, SQS and more in your serverless projects
  • Implement OAuth 2.0 Authentication and Authorization with AWS Cognito
  • Document your serverless APIs using API Gateway and Swagger
  • Learn Serverless Best Practices
English We used Node.js 6.10 runtime in the last lecture. So, I wanna quickly show you the same example using Node.js 8.10 runtime. So, inside the Lambda function, we simply switch the Runtime from 6.10 to 8.10 and Save the function and, its still going to work, because this JavaScript code is valid in Node JS 8.10 as well. So, let’s test it out. And we can see that it is working well. And if we wanted to use the async/await feature that’s supported by new Node 8.10 runtime, we can do that as well. So what I’m going to do is simply add async here before the function definition. And in that case, we won’t have a callback. So we remove the callback. And inside the function, instead of the callback, we simply return the message. Just like that. We don’t need to await anything here, so I’m not going to use await operator. So, save the function. And let’s test it out. And its working fine. So it’s still a great day today! And if we go back to our API in the browser and test it, its going to work. We don’t have to re-deploy the API in this case, because we did not change anything in the API Gateway. So refresh this page, and we can see that it’s still working. Just to demonstrate that the API is actually showing the response from our new Lambda function running on Node 8.10, lets go back to Lambda console and change our message strings slightly. So what I’m going to do is simply add an extra exclamation marks to each of these message strings. And save the function. And now if we refresh the browser, we should see messages with two exclamations marks. And its working as expected. So it’s still a great day today! Awesome! So thank you for your time and in the next lecture, we look at some key features along with some pros and cons of Serverless Architecture.