Getting started with serverless on AWS

AWS May 11 2020

If you're looking to get started building serverless applications on AWS, this resource guide is for you! I've gathered tutorials and example projects of my own that will help you progressively grow your skills and comfort level with serverless.

Jump to:

What's in this resource guide

  1. Set up a static website served from S3
  2. Interact with an external API from your static website
  3. Get started with a framework
  4. Build a Lambda function that's invoked by API Gateway
  5. Build a Lambda function that's invoked by CloudWatch Events
  6. Build a Lambda & API Gateway app that sends messages using SES/SNS
  7. Build a Lambda function that writes to DynamoDB

What's in this resource guide

This guide is for anyone interested in learning to build serverless applications on AWS. The only prerequisites are beginning coding experience (I took Python and Javascript intro courses on Codecademy) and an AWS account.

I found that I learned best by starting small and steadily adding in more services, increasing the complexity of my applications over time. The tutorials below start with simple static websites hosted in S3. By the end, you'll be able to build an application that uses Lambda, API Gateway, CloudWatch Events, S3, SNS/SES, and DynamoDB.

To stay motivated while I'm learning, I like to use tutorials as references while building projects of my own. For each tutorial, I've included one of my projects that uses the same concepts in the tutorial to provide you with ideas.


1. Set up a static website served from S3

A good place to start is hosting a static website from an S3 bucket. You can do so with just a few lines of HTML, like this tutorial does:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>My Website Home Page</title>
</head>
<body>
  <h1>Welcome to my website</h1>
  <p>Now hosted on Amazon S3!</p>
</body>
</html>
  • Example project: I made a Tarot card reader using interactive fiction writing tool Twine. You can export stories in Twine as HTML and host it just like in the tutorial above. Here is the static HTML file that's serving my site.

2. Interact with an external API from your static website

This tutorial covers the basics of working with an external API. With limited experience working with APIs, I found it useful to first practice calling an existing API before building and interacting with my own API.

3. Get started with a framework

Now is a good time to start using a serverless deployment framework. Using a framework lets you define your application as infrastructure as code, as opposed to writing code or configuring resources directly in the AWS console. Infrastructure as code makes building complex applications much easier to manage. I use the Serverless Application Model (SAM), and the Serverless Framework is another popular choice.

For the remaining tutorials, I've included an example Serverless Application Model (SAM) template. The SAM templates aren't tied to the tutorial or the example project, but they should help you as a reference to define similar functionality in your own template.

4. Build a Lambda function that's invoked by API Gateway

Here we'll build our first Lambda function and invoke it through API Gateway. Using API Gateway allows you to trigger Lambda functions when users land on your website or click a button.

5. Build a Lambda function that's invoked by CloudWatch Events

Another way to trigger a Lambda function is to create a CloudWatch Event that will invoke your function on a schedule (ex, once a week or once a minute).

  • Tutorial: Schedule AWS Lambda Functions Using CloudWatch Events

  • Example SAM template

  • Example project: This and the next two examples are within the same project, my application that sends daily Chinese vocab to subscribers. Building up a small project from a simple architecture and adding complexity and features over time has been a great way to learn new technologies.

    I use a daily CloudWatch Event to trigger a function that sends vocab emails to my subscribers. Below is a diagram of the earliest version of this application. Check out this blog post for more details.

First architecture diagram of Haohaotiantian

6. Build a Lambda & API Gateway app that sends messages using SES/SNS

With Simple Email Service (SES) or Simple Notification Service (SNS), you can send messages from a Lambda function. This SES tutorial for sending emails can be easily adapted for SNS to send email or text messages. While SES has more advanced functionality for emails, I found SNS a little more straightforward to try out first.

7. Build a Lambda function that writes to DynamoDB

Adding DynamoDB will allow you to have a data store in your applications. This DynamoDB core components guide was a great read to start with.


With these components - Lambda, API Gateway, CloudWatch Events, S3, SNS/SES, and DynamoDB - the possibilities of applications that you can build are endless.

Happy building!

🐿️

← Back Home