AWS Serverless Applications using SAM -Basics

Jawadhasan
7 min readJul 12, 2022
Photo by Richard Horvath on Unsplash

Introduction

In one of previous posts we’ve discussed AWS Cloud Formation Service and how it helps us manage our infrastructure as code and simplify deployment tasks on AWS.

AWS Serverless Application Model (SAM) takes it to the next level by simplifying the deployment of serverless resources.

The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to express functions, APIs, databases, and event source mappings.

SAM builds upon CloudFormation service and CloudFormation Templates. So, it is not a new service but is an extension of AWS CloudFormation. You can define and deploy serverless SAM and non-SAM resources using SAM.

In this post, we will take first steps and setup a SAM template which will automate the packaging and deployment of a simple lambda function and wire it up with AWS API Gateway, so it can be triggered by an HTTP Request.

What we will be Building

As this is an introductory post, we will keep it simple. The following picture shows the AWS resources, we’ll be defining and deploying using AWS SAM:

This is a very common arrangement; a Lambda function which can be triggered by API Gateway on receiving HTTP web Request.

First, we’ll define and deploy a simple Lambda function using SAM. Later, we will see how simple it is to setup and deploy an API Gateway using SAM (Events property). In later posts, we will extend this example and define and deploy other serverless resources as we progress.

Serverless Resources

Following are the examples of Serverless Resources which we can work with using SAM:

AWS::Serverless::Function

AWS::Serverless::Api

AWS::Serverless::SimpleTable

AWS::Serverless::Application

AWS::Serverless::HttpAPI

--

--

Jawadhasan

Software Solutions Team Lead | Cloud Architect | Solutions Architect