What Is Serverless?
Published: 2022-03-09 12:19:37

As we continue throughout the technology and engineering space, the goal appears to be the continuing of making components as abstracted as possible.

First, there was virtualization that abstracted the need to manage servers directly. Then, there was the cloud where an engineer doesn’t have to worry about the hardware at all.

Now, there’s serverless.

In this blog post, you’ll learn about what serverless is, why it’s important, and how you can get started in AWS today.

## Why Serverless?

Since the inception of computers, there’s been a workflow; *take software and run it on hardware*. That hardware was mainframes, computers, and servers. The hardware had software running on it, which was an operating system. Eventually, those operating systems had software running on top of them. As you can imagine, and may even deal with in today’s world, there are a lot of hoops to jump through to get an application on a computer or server. It’s essentially a bottleneck for developers.

Now, developers can get an application running without that hardware.

Instead of setting up an EC2 instance, figuring out storage needs, having proper failover, and conducting scalability, you can just put the code in serverless.

Serverless, simply put, is a service that you can use to run code.

I do want to point out something crucial; serverless is to run code. That doesn’t mean you no longer need a network, a database, or any other requirement for your app to run properly. All of those things are still needed and general cloud/infrastructure/networking knowledge is still needed. The only difference is now, serverless makes it a bit easier to run the code.

## Benefits To Engineers

With the idea becoming more mainstream, developers and engineers have a ton of benefits.

From an infrastructure/cloud engineer perspective, you don’t have to rush to get the hardware out the door for developers to test code or to run in production. Instead, you can focus on value-driven work. Troubleshooting servers and being on-call for those servers can be thought of as a thing of the past. You can now focus on the work that your organization truly needs you to do.

From a developer's perspective, you don’t have to wait for servers to be spun up to test your code. Instead, you can have a fully functioning serverless system running to test, deploy, and ship code.

The biggest benefit of serverless is that code can be tested and run without a heavy need for infrastructure/cloud infrastructure. There will always be some need (like databases), but you don’t have to have several components set up before you can actually test code and ensure that it works. Testing locally is fine, but testing in an actual cloud service makes it as “real world” as possible, especially if that’s where you’ll be running the production code.

## Getting Started With Lambda Functions

Now that you know why serverless is important in today’s world and how it can make your life easier, let’s talk about how to get started with Lambda today.

First things first, log into your AWS portal and go to the Serverless page.

### Create A Function

Next, click on the orange **Create function** button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rfauf8nbvds02zdaw93h.png)
 

From the Create function screen, you’ll have a few options:

- Author from scratch: You put the code in that you wrote. It’s 100% your customization.
- Use a blueprint: Use sample code
- Container image: Deploy a Docker container as a Lambda function
- Browse serverless app repository: Deploy an app that someone else already configured

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6e89zm5cn7paycr8fwzl.png)
 

Let’s choose the **Use a blueprint** option so we don’t have to worry about writing custom code.

Type in `hello-world-python` and choose the Hello World sample as shown in the screenshot below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dw690ly1xsh6xgryealn.png)
 

Click the **Configure** button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zurqbsdqjnbi59kj7m4k.png)
 

Choose a name for your function. For example, `helloworldpythontest`

For the execution role, you need a role that has Lambda permissions. You can either choose an existing if one is available or less AWS create one for you.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7v4gobey3psyny3iawzl.png)
 

For the code itself, it’s a simple function that echos back values. The Lambda Function itself is using the Python 3.7 runtime.

Click the orange **Create function** button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ao4d37dr9oiarfemd4j.png)
 

### Run A Function

With the Lambda function created, it’s time to give it a run!

Click the orange **Test** button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/62i54gqq9dq1wo8pxdzw.png)
 

Keep the test as the default as it’s built specifically for a `hello-world` template, which is the type of sample app we’re using. Ensure to put in an Event name, which can be anything you’d like.

Click the orange **Create** button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6fbzzee71zmcugf1ajd.png)
 

Back at the Function screen, click the orange **Test** button again and you’ll see the results as shown in the screenshot below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u1jjb1a3x0m7umjmdo1b.png)
 

Congrats! You’ve successfully built your first Lambda function.