ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

Follow publication

Creating AWS Lambda Applications With SAM

Daniel Weibel
ITNEXT
Published in
19 min readNov 2, 2018

--

In this article I’m going to explain what the AWS Serverless Application Model (SAM) is and how it can be used to create AWS Lambda applications.

The Problem

Many AWS Lambda tutorials ask you to start by creating a new Lambda function in the AWS Console, where, soon after that, you are treated with the following interface:

This text editor looks suspicious. Is it a suggestion that you should write the code for your Lambda function in there? Can it be, that in the age of Infrastructure as Code (IaC), where everything is written to files and version controlled, the code for your Lambda functions has to live in a fiddly text editor on the AWS website?

No, not at all. The real way to do this is with the AWS Serverless Application Model (SAM). SAM is the IaC solution of AWS for defining and deploying Lambda applications without the need to ever touch the AWS Console. This article explains how to use SAM.

The Final Product

In this article, we are going to build, step by step, the following AWS Lambda application. All this will be created “as code” with SAM, without the need for a single click in the AWS Console:

The application consists of an API Gateway, a Lambda function, and a Simple Notification Service (SNS) topic. When the API Gateway receives an HTTP request, it triggers the Lambda function, the Lambda function publishes a message to an SNS topic, which results in an emails being sent to all the subscribers of the topic.

The complete code of the application is available on GitHub.

AWS Lambda Basics

First of all, some important basics.

Lambda Functions vs. Lambda Applications

A Lambda function is a piece of code (managed by AWS) that is executed whenever it is triggered by an event from an event source. A Lambda application is a cloud application that includes one ore more Lambda functions, as well as potentially other types of services.

--

--

Published in ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

Written by Daniel Weibel

Systems Programming | Software Development | Cloud Engineering | UNIX/Linux | Go | Kubernetes | AWS

Responses (14)

Write a response