AWS Lambda | AWS API Gateway Lambda | AWS Training | Edureka

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] we all love finishing our tasks in the best possible manner with the least amount of time and stress serving the same purpose is aws lambda aws lambda allows you to deploy applications without having to worry about configuring the servers thereby reducing effort and increasing productivity so if you want to know more about this amazing serverless compute here is verjiha from edureka with an exciting new session on aws lambda before we start off with this session let's take a look at today's agenda we're going to start our discussion by understanding what exactly is aws followed by a brief look at the services that are provided by aws then we shall take a look at what is aws lambda and how it actually works we'll also be taking a brief look at the pricing of aws lambda and finally i'll be showing you a hands-on demonstration of how to use the lambda service so before we begin just make sure you subscribe to our channel and hit the bell icon to stay updated with all the latest edureka videos also if you are interested in getting an online training certification in aws check out the link given in the description box below so without any further delays let's move on what exactly is aws aws as many of us know stands for amazon web services which is a cloud service from amazon it provides services in the form of building blocks and these building blocks can be used to create and deploy any type of application on the cloud these services or building blocks are designed to work with each other and result in applications that are sophisticated and highly scalable so taking a look at some of the services that are provided by aws there are a number of services provided by the aws cloud platform now these services are categorized under various domains such as compute storage database migration network and content delivery management tools security and identity compliance messaging etc the compute service is used to process data on the cloud by making use of powerful processors which serve multiple instances at a time storage and content delivery storage as the name suggests is used to store data on the cloud remember that this data can be stored anywhere when it comes to content delivery it is used to cache data nearer to the user so as to provide low latency database database domain is used to provide reliable relational and non-relational database instances managed by aws networking services include those services which provide a variety of networking features such as security faster access etc management tools include services which can be used to manage and monitor your aws instances security and identity services for user authentication or limiting access to a certain set of audience on your aws resources application services application services include simple services such as notifications emailing and queuing etc so now that you have a brief idea of what is aws and the services it provides let's move on and take a look at one of its core service that is aws lambda so what exactly is aws lambda according to amazon aws lambda is a serverless compute service this means the developers don't have to worry about which aws resource to launch or how they're going to manage them all they have to do is just put the code on lambda and it gets executed it's as simple as that this not just helps in saving time but it also allows you to focus on the core competency that is app building or the code itself aws lambda is used to execute your backend code by automatically managing the aws resources when we say manage it includes launching or terminating instances health checkups audio scaling updating or patching new updates etc so how does lambda actually work the code that you want lambda to run is known as a lambda function now as we know a function runs only when it is called isn't it here the event source is the entity which triggers a lambda function and then the task is executed let me take an example in order to make you all understand this suppose you have an application for image uploading now when you want to upload an image there are a lot of tasks that are involved such as storing the image resizing it applying filters compression etc now this task of uploading an image can be defined as an event source or the trigger this trigger is used to call the lambda function and then all these tasks can be executed using the lambda function in this example a developer just has to define the event source and upload the code so now let us take another instance of the same example in this instance we'll be uploading images in the form of objects to an s3 bucket this uploading of an image to an s3 bucket will become an event source or the trigger the whole process can basically be divided into five steps first the user uploads an image or the object to a source bucket in s3 which has the notification attached to it for the lambda function this notification is read by s3 and it decides where to send the notification then s3 sends the notification to lambda and this notification acts as an invoke call for the lambda function execution role in lambda can be defined as an iam or identity and access management to give access permission for the aws resources for this example where we've used s3 bucket finally it invokes the desired lambda function which works on the object that has to be uploaded to the s3 bucket now if you were to solve this scenario traditionally along with development you would have to have hired people for managing various tasks such as size provision and scale-up group of servers managing the operating system updates applying security patches and also monitoring this infrastructure for performance and availability now this would have been an expensive tds and a tiresome task therefore the need for aws lambda is justified aws lambda is compatible with nodejs python java etc all you have to do is upload your zip file define an event source and you're all ready to go so by now you would have understood what is aws lambda and how it actually works moving ahead let us understand where to use the lambda compute service and also a brief comparison between lambda and other aws compute services so now to understand this part of the session consider that you were an architect and you need to design a solution for some problem now as an architect you have various aws services that can be used to execute a task now these services can be anything such as the aws ec2 aws elastic beanstalk aws opsworks and aws lambda aws opsworks and aws elastic beanstalk are used to deploy an application so our use case is not to create an app but to execute the back end code then why not ec2 so aws lambda versus aws ec2 if you were to use the aws ec2 service you would have to architect everything that is the load balancer ebs volumes software stacks etc in the aws lambda service you don't have to worry about anything all you have to do is just insert your code and the aws will manage the rest for example in ec2 you would be installing software packages on your virtual machine which would support your code whereas in lambda you don't have to worry about any virtual machine all you have to do is just insert the plain code and lambda will execute this for you now at this point i want you all to know something very important if your code will be running for ours together and you expect a continuous stream of requests you should probably go with ec2 this is because the architecture of lambda is for a sporadic kind of workload wherein there will be some quite rs and some spikes in the number of requests as well say for example logging the email activity for a small company now a small company would have more activity during the day than the night also there could be days when there are less emails to be processed and sometimes the whole world could start emailing you in both the cases lambda is at your service considering this use case for a big social networking company where the emails are never ending because of its huge user base lambda may not be an app choice so that was about ec2 and lambda i hope you guys have understood where to use lambda and where to use ec2 now moving on and understanding the pricing in aws lambda like most of the aws services aws lambda is also a pay-per-use service this means you only pay for what you use therefore you are charged for the number of requests that you make to the lambda function and the duration for which your code executes when it comes to the requests you are charged for the number of requests that you make across all the lambda functions aws lambda counts a request each time it starts executing in response to an event source or invoke call including a test that is invoked from the console the duration is calculated from the moment your code starts executing till the moment it returns or terminates now this is rounded up to the nearest 100 milliseconds the price depends on the amount of memory you allocate to your function so now moving on towards the most interesting part of the session which is the hands-on demonstration of aws lambda service now if you don't have your account in aws lambda and want to create your own account please make sure to check out aws crash course video of edureka now presuming that you guys already have an account and have logged into your aws console let's move on and take a look at how to create a lambda function okay so creating a lambda function now like i've already mentioned before the first thing that you will have to do is open up the aws console now if you already have an aws account just log into your account else if you're creating a new account please make a note that aws will provide free services for an ear and if you wish to know more about this check out the aws free tire services page on amazon's official website now since i already have an account what i'm going to do is just log into my account and get started okay now as you can see on the screen this is the aws management console as you can see there is a huge list of services that are provided by aws now if you just scroll down you will notice that the lambda service is present under the compute section so just click on that to move on to the functions list page now this page basically shows the functions that you have created in the current aws region please make a note that recently created functions might not immediately appear and it may take a while for them to show up so as you can see this page has several options such as create function filter actions etc also if you are a returning user who has already created some lambda functions you will see a list of functions that you have created else this list will be empty now if you want to create a lambda function simply click on the create function option that is present at the right top corner of the page also if you can notice the actions drop down list is not clickable this is because the actions are to be performed on the lambda functions that are already created so if you do not have any function you will not be able to click on the actions drop down list however if you have some function present already select the function and you will see that the actions list gets enabled and it provides three options that is view details test and delete as the name suggests the three actions will help you view the lambda function details test it or delete the function if it is no longer required now since we are focusing on creating a lambda function let me just click on the create function option okay so this is the create function page as you can see there are three options that are present over here the first option that is author from scratch allows you to create a lambda function completely on your own so if you want to create your own lambda function just given a suitable name and specify the runtime you prefer in our case the name of the function will be hello world the runtime or the language that i'm going to make use of is python you can go ahead and select any runtime that you wish to use okay so i'll just select python 3.8 so next up after runtime you see something called as permissions now this basically refers to the function permissions by default lambda will create an execution role with permissions to upload logs to the amazon cloudwatch logs amazon cloudwatch logs is nothing but a monitoring and management service it provides data and actionable insights for aws hybrid and on-premises applications and infrastructure resources when you make use of aws cloudwatch you can collect and access all your performance and operational data in form of logs and metrics from a single platform however the default role can be customized later when you wish to add triggers okay so now i'll just go ahead and click on the create function option now it is going to take a few minutes to do so okay so let us wait for the same now once the function has been created you will see the message just as you can see on the screen that is successfully created the function hello world which is the name of the lambda function that i just created now this page basically allows the user to manage the code and the configurations once you have provided the required code and its configurations simply click on the test option in order to execute the code now before doing that let me walk you through this page the first element that you see over here is the page configuration this page has something called as the designer here you can add triggers layers and destinations to the lambda function that you've created a trigger over here refers to an aws service or a resource that is used to invoke the lambda function now if you want to connect your function to a trigger click on this add trigger option as you can see there is a drop down list over here with a huge list of triggers that you can choose from choose a service from the list you can choose a service from the list to see the available options now for the first part of this demonstration i'll not be using any of these so i'll just click on cancel and i'll get back to the previous page so the next thing that you see right in the middle of the screen are two options that is the function that you've just created which in my case is hello world and layers by default the function is selected and when you scroll down the page you'll be able to see the code editor and a sample code that has been generated automatically for my function so now this is a very simple function it is called as the lambda handler which simply returns a message saying hello from lambda the code editor in aws lambda console enables you to write test and view the execution results of the lambda function code for the purpose of this tutorial let me just change it to hello from edureka and then i'll just save it okay now let's scroll back up and select the layers option so layers are resources that contain libraries a custom runtime or other such dependencies you can create layers to separate your function code from its dependencies now by default as you can see no layer has been added to add a layer all you have to do is click on layers and then choose add a layer option to include libraries in a layer place them in the directory structure that corresponds to your programming language now since we have a very simple function i'll not need any extra layer for it but for the sake of showing you guys let me just click on add a layer option okay so as you can see there is a drop down list present over here as well when you click on this you will be able to see that by default there are two layers present over here one is for perl and the other one includes sci-fi library for python 3.8 also there are two other options that are present over here one is custom layers and the other is specify an arn in the custom layer option you will see any of the previously used or created layers since i have not used any my list is blank the next option is to use an arn arn stands for amazon resource name entering an arn will enable you to use a layer that is shared by another account or a layer that does not match your function's run time the format in which you should specify an arn is shown in the text bar itself okay so now let's get back to our previous page okay so i'll just click on cancel now towards the right side of this page is something called as destinations destinations are aws resources that receive a record of an invocation after success or failure now you can configure lambda to send invocation records when your function is invoked asynchronously or if your function processes records from a stream to add a destination choose add destination option the contents of the invocation record and supported destination services vary by the source so the next element that is present on this page is permissions like i've already mentioned before the default execution role that was used for this hello world lambda function has the permission to store logs in the amazon cloudwatch logs now this is the only permission that we have as of now the resource permissions can vary depending on the role that you select for your function finally there is something called as monitoring now when you click on this monitoring element you can see some graphs which do not show any data as of now this is because i've not invoked my function yet once the function has been invoked you'll be able to monitor trace and debug your lambda functions so coming back towards our hello world function so let me just scroll down to the code editor so now to invoke this function i will have to test it before clicking on test let me show you the default test event now you can open the test configuration either by clicking on select test event dialog box or by opening the drop down list that is present next to the test option in the code editor so let's click on configure test events now you can see there is some default test event present over here also by default the create new test event option has been selected the other option that is edit save test events cannot be selected as i have not created any test event before so let's just give some name to this event i'll say event1 and click on create so now our function is all set to invoke this lambda function i'll have to click on the test option like i've already mentioned before okay so let me just click on that now as you can see i have a dialog box that says execution result has succeeded when you open the details you will be able to see the summary and the log output the summary section shows the key information such as the time taken for the execution build duration which is 100 milliseconds request id etc that are reported in the log output the log output section will show the logs generated by the lambda function execution now when you check the monitoring page this time you will see that all the metrics here would be updated for instance let me hand over the error count and the success rate metrics as you can see it clearly shows that our program has executed with hundred percent success rate and zero errors similarly you can check various other metrics such as the number of invocations the duration etc now let us do something that will show us okay so now let us do something that will show us the real-time metrics what i'm going to do over here is add a trigger and that will be an api gateway this way i'll be able to see how many times my function has been invoked the average duration etc so let us go back to the configurations element and click on add trigger then i will open this drop down list and i will select api gateway so over here i will create an api with the default http api type and i can keep the security open as this is just for demonstration however please make a note that in real world scenarios this is not the case the name will just be hello world api and the deployment stage will be default so just create the api so now as you can see on the screen i have an api endpoint over here let me just open that link in a new tab and i will repeat the same thing a few times i've opened that link in four new tabs and now i'll get back to our console i'll open the metrics page and let's see what happens so as you can see i have some real time data that is present over here i have four invocations the corresponding minimum and maximum duration etc so now there are many more things that you can do with aws lambda functions however for the sake of this session we won't be getting into any further details however there is one last and important task that is left once you're done using your lambda function make sure that you delete it to do so all you have to do is click on the actions drop down list and select delete function option so congratulations guys you have learned how to create and manage your aws lambda function which is very important in learning how to run applications without needing to provision or manage servers so this brings us to the end of the session i hope you guys have enjoyed and learned something new in case you have any doubts or queries please do let me know in the comment section and i will revert to you at the earliest we'll be back with more and more exciting sessions but till then good bye and take care i hope you have enjoyed listening to this video please be kind enough to like it and you can comment any of your doubts and queries and we will reply them at the earliest do look out for more videos in our playlist and subscribe to edureka channel to learn more happy learning you
Info
Channel: edureka!
Views: 13,878
Rating: undefined out of 5
Keywords: yt:cc=on, aws lambda, aws, aws lambda tutorial, aws lambda tutorial for beginners, aws lambda function, aws lambda python api gateway, how aws lambda works internally, how aws lambda works, how to use aws lambda, aws tutorial, how to create api in aws lambda, how to run python code in aws lambda, how to deploy aws lambda, how to add layer in aws lambda, aws lambda example, how to deploy python code in aws lambda, aws lambda python, aws edureka, aws lambda python example, edureka
Id: SGudMFFa3Gw
Channel Id: undefined
Length: 23min 45sec (1425 seconds)
Published: Thu Oct 08 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.