Introduction to serverless on AWS


2 min


Serverless is a cloud-native development model that allows developers to build and run applications without having to manage servers.

While serverless literally means " without servers ", they are always present but abstracted from the development of applications. Thus, the tasks of provisioning, maintenance and scaling of the infrastructure are performed by the cloud provider and the customer can focus his efforts on the development of his code.

What are the main benefits of serverless?

While a serverless architecture offers many benefits, it does not suit every type of application and there are a couple of limiting factors to consider, such as:

A serverless architecture on AWS:

AWS pioneered the serverless model by launching the AWS lambda service in 2015.  Lambda  is a serverless compute service that allows you to run code in response to events for  almost any type of application or backend service. All you need to do is provide your code in one of the supported languages (Node.js, Python, Java, Go, .Net, Ruby).

Today AWS offers a dozen serverless services, called managed services, on 3 layers: compute, integration and data storage. Below is an example of a full serverless architecture on AWS for a simple web application.

Here, several AWS serverless services are used. First of all, there is Route53 which allows the management of DNS. Then there is CloudFront which acts as a CDN and therefore allows the caching of certain resources. It is linked to the Certificate Manager service, which ensures the installation of SSL/TLS certificates on the domain name. Then we have API Gateway, which acts as the API that connects our user with the application. Combined with the Cognito service, it is able to reject the request if the user is not authenticated or authorized. Otherwise, the request follows its course. It can either go to the S3 service, if the data to be retrieved is static (like an image for example), or to the Lambda service which will act as the back-end of our application. In the last case, our back-end will be able to communicate with a DynamoDB database, to retrieve information related to the user.

All the services used here are serverless, and work perfectly without the need to set up a server. So, if no requests are made, it is possible to not spend a penny. And conversely, if the load were to burst, our infrastructure would be able to scale without any problem.

Bonus: How to build an API Gateway?

Steps to build an API Gateway:

  1. Create an AWS Lambda

a.Log into your AWS console, and go to the Lambda service

b. Click on "Create function".

c. In the form, fill in the following items:

i. Function name: "my-first-lambda

ii. Runtime: Python 3.9

d. Finally click on "Create function".

  2. Create an API Gateway

a. Go to the API Gateway service

b. Click on "Create API

c. Choose HTTP Api and click on "Build

d. Click on "Add integration" and select Lambda

e. In the search bar that appears, select "my-first-lambda

f. In "API name" enter "my-first-api" and click "Review and create", then "Create"

    3. Send a request to the API

a. Copy the url present under the name "Invoke URL", and add "/my-first-lambda" at the end.

b. Paste this url in your browser to get the answer from your Lambda : "Hello from Lambda!"

You've just deployed and used an API in just a few clicks!

Thank you for reading this article. We hope you enjoyed it!