Kick-starting Serverless: Why You Should Use AWS Lambda and Getting Started with Functions
Developing and maintaining apps is no easy task.
Not only do you have to write code, but there are also servers, scaling, stability and so on that need to be taken care of. This means that a lot of companies spend a lot of time and money on overhead and less of these limited resources on development.
Why AWS Lambda?
What AWS Lambda does is to remove the hassles that can distract teams from development and direct your limited resources to where they can add the most value.
AWS Lambda is a serverless computing platform that’s part of Amazon Web Services (AWS). It works by letting you upload your code to a platform where that code runs according to criteria you specify. Server maintenance and scaling are taken care of by AWS Lambda, which frees up a lot of development time. With this level of abstraction there’s a lot of mind-bogglingly complex automation that can otherwise sap precious time. Security, monitoring and logging are all done through the AWS console, which is essentially the dashboard for the AWS ecosystem. It can also be accessed through a mobile app.
Another major advantage of choosing AWS Lambda over running your own servers is that it removes the restraints of configuration requirements. It creates a level playing field for the app to run on, without having to worry about whether or not it will run as it did after testing. All of this means that AWS Lambda offers a level of abstraction that is on par with, or even higher than, that of containers. Even containers need to be maintained to a certain extent because of their lifecycles.
But how do you get started with AWS Lambda? With functions.
What are AWS Lambda functions?
When you upload your code to AWS Lambda, it is then referred to as a ‘Lambda function’, and becomes part of the Amazon ecosystem.
AWS Lambda functions are the code that you upload in a ZIP file to AWS Lambda, which then runs it for you. Another way of running code in AWS Lambda to use the inline editor called the AWS Lambda Console. The languages that it supports for now are Node.js, Python, and Java, with more planned in the future.
AWS Lambda functions are triggered by events that you configure, which also means that the code will only run when it has to, or is needed. This is done by uploading an object-created event to the S3 bucket, which works in tandem with AWS Lambda. For security purposes, AWS Lambda functions will need an execution or IAM role before they are created. Roles represent a user and they can be shared with other users who may need access to AWS resources - in this case, AWS Lambda itself. Once the AWS Lambda functions are running, your app will be up and running, and can be monitored from the AWS console.
After hearing so much about functions, you must be ready to go and try it yourself, so let’s take a look at how to get started.
Steps to get started
Assuming that you’ve already created an AWS account and have uploaded object-created events to your S3 bucket, you can follow these steps to create an AWS Lambda function:
When you’re at the AWS console, select Services > Lambda
Click on Get Started Now
Go to the Lambda > New Function page
Go to Select blueprint > s3-get-object
Now, in the Configure events section, leave the default settings, and click Skip
In the Configure function section, enter a function name and its description
Underneath that is the AWS Lambda function code section: under Code entry type select Edit code inline
In the AWS Lambda function handler and role section, select *S3 execution role
Click Allow in the IAM window and the new role name will appear in the Role field
In the Advanced settings section, change the Timeout value to ‘5’
In the Review section, click Create Function to create the AWS Lambda function
Now that you’ve seen how to start off with functions, let’s take a look at how AWS Lambda has helped others.
Who is AWS Lambda for?
AWS Lambda is great for both development and operations teams, as it frees a lot of time for developers and lets them focus purely on development, and also unburdens operations from having to worry about maintaining servers or dealing with reliability issues.
If you’ve already started out in the AWS ecosystem, then AWS Lambda will be a natural progression as it only works within AWS boundaries. The downside is that it’s a closed ecosystem, and the convenience that it offers comes at the cost of some flexibility. Even with a general lack of flexibility, there are some killer use cases for AWS Lambda, such as automated backups and, of course, operating serverless websites.
Netflix is one of AWS Lambda’s biggest users. Netflix handles a huge amount of code and must cope with enormous demand. AWS Lambda’s event-based rule management takes away a lot of burden that comes from having to manually scale and maintain servers. With files being pushed by studios all the time, and demand constantly on the rise, AWS Lambda’s abstraction massively increases efficiency.
Serverless computing is the way of the future, and AWS Lambda is the most complete offering available today for those who want to be part of this future as it takes shape.