AWS Lambda is a serverless and event-driven compute service. It allows you to upload a piece of source code to execute against a valid event. The uploaded piece of code is called a Lambda function. At the time of writing this chapter, AWS Lambda supports Java, Node.js, C#, Ruby, Go, PowerShell, and Python programming languages. In the case of EC2 instances, you are charged for each running second. It is important to note here that, until mid-2017, AWS used to charge on an hourly basis for EC2 instances. In the case of AWS Lambda, charges apply for code runtime in increments of 100 milliseconds. Notably, charges are not applicable to uploading code. AWS does not charge you for just creating and keeping a Lambda function; you are charged for the amount of time it takes a Lambda function to run.
You can create Lambda functions that run on events so that (as...