AWS Lambda Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so let's get start with the lender so I'm going to tap lambda in my search bar and I'm going to get to lend that console so you may be on this screen or you may be under another screen and actually I want to get to the other screen so I haven't found a way to get there consistently we using click options so I'm just going to tap begin in the URL so my region pound slash begin and press enter and this takes me to this nice screen which i think is good for educated purposes nothing you need to do for getting the hands-on respond show you how lim that works before we write our first lender function so lambda is a server light service on AWS where you can only pay for what you're going to use in terms of compute usage and so there's no charge when your code is not running so there is how it works box that are really liking here which is ok here is our JavaScript code and this is a function and the function is just returning the word hello word and so if we run this and this is a lambda function the lambda function has just run and now we have the result hello world this is very very simple but we can have a lot more complicated than the functions in there that just do a lot more than just saying hello world okay so next if we look at lambda we can see that lambda responds to events that happen so here's my Lynda function and currently it's being invoked by streaming analytics and so as we can see in this little log box in here it just keeps on saying hello world and this demo is quite interesting because we can see from here that the data can from can come from data processing or innisfree buckets it can come from little photography it can come from streaming analytics it can come from mobile and IOT devices so if I click on the mobile then it goes and sends a message to the backend which goes straight into lambda and so if you can see the more I click on these things the more there are cog wheels on the right hand side which shows that mainly lambda functions are being invoked and as there is less data and less invocations are not being sent then there's less cogwheels so the lender function if I click a lot on this mobile device as you can see scales accordingly to what it looks like and if I click on scale skin see now we can look at the invocation and the cost so if there are very little invocations as you can see the cost is almost zero and as I start invoking more and more my lambda function the number of my invocations goes up the concurrent she goes up and then the cost starts going up as well but as we can see for exists an example for example I have four million invitations and a cost of three dollars so it is really a little amount of money so this is the whole power of lambda here with ATIS lambda we can see that we scale based on the load that we have we can integrate with many different backends and the more we send events the more we have to pay and only that so the cost is really linked to the number of invitations and how long these invitations lasted so just a cool demo but I think it's good for educational purposes and so next we click on create a function and if you had to have on the screen then you can just click on create function right here and you get to the exact same screen okay so we're all in the same place now hopefully and so to create a function we have three options we can author it from scratch and it starts with a simple hello world example we can use a blueprint and this will use some kind of predefined lambda function for us or we can browse a server less app repository which contains a bunch of apps created by public people and so on so in here I'm just going to use a blueprint but we could also author hunt scratch and so in the blueprint I'm just going to type in the world hello and this takes me to - hello L there is hello world and hello world Python and so I'm going to click on this Hallowell Python for now it's bye from 3.7 but maybe in the future will be pleasant proven 3.8 or something like this it doesn't change anything okay just click on hello world Python and you don't need to know Python in advance to understand what I'm going to do it's just that I think it's a language it's easy to read and understand so click on hello l Python and then click on configure and we're getting to the blueprint configuration so this function I'll name it hello world and then I have to choose an execution roll now a roll is a I am roll that will be attached to our limit function that will allow us to execute stuff for our limit function and tell us what it can and cannot do for example for interacting with ec2 or s3 or whatever so for this role I'm going to create a new role with basic lambda permissions and this role will be created for me and what it will come is that it will come with permissions to upload the logs to Amazon CloudWatch logs so this is a basic permission roll for lambda which allows them that you just lug what does into calvache so this makes sense and the real creation will take a few minutes and then the row will be named something different for you but form is B hello weld roll and then this blob of text in here okay now the code itself it's a blueprint so I'm not going to modify it but here is a very simple lambda function in Python where we have a function which is a Lynda Handler and what it does that it prints a lot of stuff to the console so value 1 equals event key 1 by H 3 equals even key 2 and so on and then finally the result it returns is event key 1 to echo back the first key value it's just a very simple function which doesn't do anything fascinating but it you're sure that lambda functions can execute code that's arbitrary so we'll click on create function and get going so now as we can see the function has been created and we can test it so I'll click on tests and then I'll create a new test event I'll call it from the hello well template and I'll call it simple event and this will contain just a JSON document with key 1 value 1 key - value 2 and key 3 value 3 and this will be the event will use to invoke our limited function so I click on create and now the event has been created so now if I click on tests I should be able to test my lambda function and the execution result is succeeded so if I look into the details it shows that the result is value 1 and if I scroll down it shows the log output of the function that happened while it was executing so it says value 1 equals value 1 value equals value 2 and so on which is the output of the function code that is in here in the bottom so as we can see other things that interesting is that the duration is 1.54 millisecond so it was really quick to execute but I've been billed 100 milliseconds because we get built-in 100 milliseconds increment in lambda for now in terms of the resource configured 128 is the default so this is what's been configured for this blueprint and the actual memory usage has been 256 megabytes so I know how I'm doing versus the memory are provisioned and the memory actually used ok so this is really cool we can also go and click here to view the logs in climate law group so if I go into cloud watch in here I'm able to find this log group called a torus Lambda Halliwell and there's a log stream and in this log stream I'm able to find the exact same log that was in here in this window back into cloud watch lugs okay so this is excellent and then what else can I show you if I scroll down I'm able to modify the code if it's very simple code so in here what I can do is instead of returning event key one and I need to comment this out and I uncomment the one that says rise exception something went wrong so I'm going to save my function in here and then after setting my function I can test it again so I'll test it and this time the execution result has failed and so we have the error message something went wrong and we have this typed race and so on and we can look at the log output as well and see what happened so the really cool thing here is that we are also able to see this log output in flour slugs so if I click on this execution right here I should be able to see the exact exception that happened and so on so this is really helpful for debugging okay so this is it's just for a quick overview of lambda obviously we'll do so much more with it but before we move on to the next lecture I'm going to uncomment the good code and comment the code that raises an exception and then click on test save and then click on test and as we can see everything is green so it succeeded so that's it just for an intro to lambda and the last thing I want to show you is that if we scroll down we can see that this hello world lambda function is linked to cloud watch lugs so this is because we have given our lambda function and I am role to get access to cloud wash lugs okay and so there is a clink link here called manage these permissions so this is it's saying why we have these permissions so this takes me straight into the I am management console and so if I went back into the roles by the way and just type hello world and search for it I should see the hello world this one the hello world role and with the blob of text so this is a lambda function I am role and there's been a basic permission applied to it which is a managed policy which is the a SS lambda basic execution role and this policy allows two things it allows to create a log group so create a log group for the cloud which logs which allowed it to create this log group right here and the second thing it allows to create log stream and put lug events to the lug groups that it created and this is great because now we are able to see the lugs in Erlander function in here thanks to these AI and permissions and this is the only I M permissions your lambda function needs to lug it stuff to cloud watch and this is why in this UI you can see that the lambda function is linked to Amazon CloudWatch logs okay well that's it for this lecture I hope you liked it and I will see you in the next lecture
Info
Channel: Stephane Maarek
Views: 118,074
Rating: undefined out of 5
Keywords:
Id: seaBeltaKhw
Channel Id: undefined
Length: 9min 21sec (561 seconds)
Published: Thu Mar 26 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.