‫Okay, so we're going
‫to practice using the Lambda service.
‫And when you go in Lambda, you may end up on this screen
‫but there's another screen I really like.
‫And so if you're in your URL, you replace slash discovered
‫by slash begin, you may end up on this screen,
‫which I really like because it has
‫an educational value I want to show you.
‫So Lambda is here to help you run code
‫without thinking about servers,
‫and this makes it a truly serverless service.
‫So the idea is that we can use any type
‫of programming language we want, for example .NET Core.
‫Go, Java, Node.js, Python, Ruby, or any custom runtime
‫if you want to have around 10 provided by an Oprah suspect
‫for example, the Lambda restaurant time as possible.
‫And so from this code, you will have it written
‫upload it into the lender console
‫and then Erislandy will run the code for you.
‫So let's take a very simple code.
‫For example, Python
‫we have a lender handler is going to print the event
‫and then say return, hello from Lambda.
‫So let's click on run and we get to hello from Lambda.
‫So that means that the lender function just ran the code
‫that we have provided right here. Very simple. Right!
‫Next, how does Lambda functions get invoked?
‫So we can click on the run button obviously
‫but also we can have Lambda responded to events.
‫And this is what I want to shoot you I think is really cool.
‫So as we can see, events can come from various sources.
‫For example, in this one, this is trimming analytics.
‫And so as the streaming analytics is sending events
‫into a Lambda function that
‫in the function is returning hella from
‫under elephant and Dial lo from that and so on
‫but it's not just a streaming analytics.
‫If you click on the phone right here is going to
‫send a message into a mobile IOT by Ken.
‫And this IOT backend will also invoke our lender function.
‫Same for, if we take a photo and upload it into an S3 bucket
‫for data processing, then the Lynda function we've invoked.
‫But the cool thing is that
‫if you start clicking a lot on one of these sources
‫you can see on the right hand side, we have more cog wheels.
‫So as the left hand side flow
‫and invocations will index scales
‫then the number of Lynda invocations and
‫concurrent London functions running will be scaling as well.
‫So it's really cool because that means that
‫as we have more load automatically Lambda will scale
‫with our load.
‫And that is a whole power
‫of using Lambda as a compute platform.
‫And this is why alum that is serverless
‫and it scales really well.
‫So if we're going here, as we can see
‫as the limited function is invoked
‫we get more invocations over time.
‫And the customer means zero
‫because there's a free each year.
‫And as soon as we will pass 1 million invocations
‫then the Lynda function will start incurring some charges.
‫So if you go in there
‫and start having over 1 million invitations, here we go.
‫Now we're getting some sense, as you can see
‫we are at almost 2 million invocations
‫and we have only 14 cents as a cost.
‫So it's very, very
‫very cost efficient to have a Lambda function
‫and to run some workload at scale.
‫So as you can, so you can play around
‫and seeing that the more you have invocations
‫the more the cost goes, but it's really, really controlled.
‫And Linda is, can be quite accustomed saving mechanism
‫if you use it at scale.
‫So this is just for the introduction
‫to Linda and ethically can create a function.
‫We are offered with four options to create a function.
‫And for this example, we're going to use a blueprint
‫and in the blueprint, just type in hello, and
‫we'll help you use the hello world, Python, that blueprint.
‫So you click on it and we'll deploy this blueprint.
‫So configure it, the function name is just demo Lambda
‫because this is just our hello world for this course
‫we'll create a new role with basic Lambda permission.
‫So we'll leave it as the default option.
‫And then here is the code that will be important
‫into our function.
‫So this is going to be a Lambda handler that will
‫print three values into the lug and then return one value.
‫So let's click on create function
‫and now this function is being created
‫and in the second we'll be able to run it.
‫Okay. So my function is created and as we can see
‫the code has the code source in here.
‫In fact, click on Lynda function dot P Y and open it.
‫We can see that the function could we had
‫from before is now loaded into this code editor.
‫So why don't we go ahead and test this function?
‫So I'm going to click on tests
‫and we need to create a new test events
‫which is a hello world events, which contains Q1 value.
‫One key, two value to Q3 value three as adjacent documents.
‫So I'll call this one demo events
‫and click on create.
‫So now the demo event was successfully saved.
‫So if I click on test
‫now it was going to run the demo events
‫and the response is value one
‫the function log is that's value.
‫One equals two value, three equals three
‫which is just a result of this three print statements.
‫And finally, the response value is value one again
‫due to this line of code.
‫So it may look, look, look how much better
‫from a programmer's perspective, as you can see
‫you had just some code and it was uploaded into Lambda
‫and then it was run by Lambda very quickly.
‫So this is a huge improvement.
‫If you're a developer, as you can see to deploy the code
‫and have it run, but on top of it, it runs seamlessly
‫and it will scale automatically, and it is fully serverless.
‫Okay. We didn't apply any service now
‫in terms of built a duration.
‫So if you go in here and scroll down, sorry
‫then as you can see, the duration was 2.3, two millisecond.
‫We've been built for three millisecond of execution
‫and here's the memory size that we've provisioned.
‫And the one that was used
‫and how much the in it was, because this is
‫the first time that we use our lender function.
‫Now, if I run it again, oops.
‫If I go back to my functional, excuse me
‫and run this one again, as we can see now
‫the function duration was one point 33 minutes, second.
‫And on the right-hand side, there was no initiation
‫because my lung function was ready to be used.
‫Okay. So that's one way of doing things.
‫Now, the other thing is on true is that's
‫from this and the function we're able to configure it.
‫So if I go in to general configuration
‫we get some of the most important settings.
‫The first one is around memory.
‫So we can have the memory from anywhere
‫between 128 megabytes up to 10,000, 240 megabytes of memory.
‫Obviously, if you have more memory, you're going to be
‫get billed more in terms of timeouts
‫we can go anywhere between three seconds
‫or five seconds all the way to, as you can see, 15 minutes.
‫So the maximum time out is 15 minutes
‫but you want to make sure that you only use it, the function
‫for the time that you think is going to be used for.
‫And then the execution role is the one that was created
‫by Lambda in the beginning.
‫Okay. So those are some of the most important settings.
‫Okay. And the other thing we can look at is monitoring.
‫So in monitoring
‫we're able to see what is going on with the Lynda function.
‫So how many times it was invoked.
‫So here one time, how long it lasted
‫whether or not there was errors or successes and so on.
‫So it could be quite helpful, but we have integration
‫with CloudWatch metrics and also CloudWatch logs.
‫So right now we have nothing, but we could look
‫at the CloudWatch logs right now when the function runs.
‫So to do so, just a refresh
‫on the right hand side, the recent invocations.
‫And we can see that there's a log stream right here.
‫So if I click on it, I am taken directly
‫into the CloudWatch logs and we can see that
‫on the clever slugs, we have all the logs
‫of the invocation of this Lander function.
‫And this is
‫within a lab group called universal Lambda demo Lambda.
‫And then when I'm, that is the name
‫of my Lambda function within my region, obviously
‫and we have one log stream right here.
‫So we get all the logs into Lambdas.
‫And other things you can try is to modify the code.
‫For example, if we take this code, we go
‫to the Lambda function and I will come into this line
‫of code by having a hashtag and uncomment, this one
‫this is going to raise an exception.
‫So to do so I need to first deploy the changes
‫by clicking on deploy.
‫Now the trends have been deployed
‫and now I can test my function.
‫And in this type, we get a execution result
‫which is an error or something went wrong.
‫Type is exception.
‫As we can see something went wrong
‫which was triggered by this code or line of code right here.
‫So any type of error is also will be reported by Lambda.
‫And you could look into CloudWatch logs to
‫understand as well where the log of the error happens with.
‫I go back into clever slugs
‫but there's a second log stream right here
‫which I'm going to open.
‫And we get this exception right here.
‫So it's possible for us to go back as well
‫to the logs of the exception within CloudWatch slugs
‫to understand the root cause of the issue.
‫So fairly easy.
‫Now, if you want to make the function run again
‫find you just re reverse what you did and you click on test.
‫And again, now this time
‫this lender execution function will work.
‫So some of the less things we may want to check out
‫is the fact that in here
‫the runtime settings were running Python three.seven
‫in this example
‫but you may get an updated version maybe on your end.
‫And the handler is Lynda function.
‫That Lambda handler
‫which is saying to look at the Lambda function
‫that POI file and the function name Lambda handler.
‫So if you go up, we can see the function name is dilemma
‫on just construction that P Y and within it
‫we have the lender on the score handler function.
‫So this is why it knew to invoke this function.
‫Particularly also, we have written to CloudWatch logs
‫and the reason we were able to do so is
‫that if we go into the configuration
‫of our Lambda and go to the permission stabs
‫we have a role name called demo Lambda role that was created
‫for us by the Lambda console.
‫And if you look at the policy itself
‫we can see within the policy summary that we have access
‫to right to CloudWatch logs, which is something
‫you can also see right here by resource summary
‫that's clever Chagos story actions and to resources
‫which allow us to create Luxtreme stream and groups
‫and also send the logs to CloudWatch logs.
‫So this is the whole idea
‫behind this permissions tabs right here.
‫So that's it for this lecture.
‫I hope you liked it.
‫And if you are in the certified developer course on AWS
‫then get ready for an extra few hours
‫of content on and Dines you're nuts.
‫Well, this is enough for your exam.
‫I hope you liked it.
‫And I will see you in the next lecture.