"A server-less datacenter..."
We had several trends in infrastructure the last decades:
1. Breaking down the monolithic architecture: one server alone should not manage all applications
2. Virtualization: we should factorize physical server unused resources by creating multiple Virtual Machines (VMs)
3. Containerization: we should remove the OS overheard of these VMs, and isolate each app in container (Docker)
4. Serverless: do we really need to manage the life cycle of the container? Let's concentrate on the app code only...
In parallel, Cloud vendors expand their offers to make our (developers) job easier:
1. Bare metal as a Service: we manage the whole server, hardware, OS, drivers, network
2. IaaS (Infrastructure): we take care of the VM, OS patches, framework, application
3. PaaS (Platform): for example, Kubernetes / ECS / EKS, we only manage the containers, images and ports
4. FaaS (Function) or Serverless: we manage only the code, in an elastic environment, the vendor takes care of all the rest
Serverless is a dream for developers:
As we speak, many applications are getting migrated to become serverless to reduce cost and become elastic. But there are few downsides:
Lambda is a Serverless function running code from many popular languages (JS, Python, Go). With Lambda, your code will run in AWS Cloud, and you will pay only for what you use. AWS will automatically scale more Lambda functions of your app if the demand grows.
When deployed, other AWS services like CloudWatch, CloudFormation, SNS can call this Lambda to execute the code. From the outside, API Gateway integrate Lambda to provide a unified and secured way to query Lambda functions.
Api Gateway is a fully managed service to create, publish, maintain, monitor, and secure APIs at any scale. It acts as the "front door" for applications to access data, business logic, or functionality from your backend services.
Below is an example of API Gateway interface in AWS. We can see that 3 resources are declared (
GET will connect to the lambda
To deploy a serverless function accessible from an API, we need to create and configure our Lambda and API Gateway. To make the whole process easier, AWS introduced the Serverless Application Model SAM, an open-source framework for building serverless applications to express complex architecture in simple syntax.
SAM features include:
Serverless.com Framework is another popular alternative to deploy Serverless functions in AWS cloud. The advantages of this contender:
At this point, both products offer quite similar functionalities. As Terraform compares to CloudFormation, I would say that Serverless.com should be used when integrations with other Cloud providers might come in. If you are certain you will stay within AWS premises only, SAM and CloudFormation are better choices as these services are well integrated and part of the AWS support.
I setup a small demo using SAM to deploy Lambda and API Gateway on AWS Cloud. The deployment is automated with CloudFormation, and CI/CD is configured via CodeBuild.
git push from a developer in Github will launch the whole CI/CD process. SAM framework will build and deploy the CloudFormation template to create/update API Gateway and Lambda functions.
Check out the Github repo to deploy the infra.
Thank you for reading :-) See you in the next post!