If you're looking to get started building serverless applications on AWS, this resource guide is for you!
This guide includes courses and common serverless patterns with hands-on tutorials, templates, and example projects of my own. This combination will help you progressively grow your skills and comfort level with serverless. This 2023 version has been updated with plenty of new resources that will help you build your own serverless applications in no time.
The only prerequisites are beginning coding experience (I took Python and Javascript intro courses on Codecademy, you can read more in this post) and an AWS account.
Jump to:
Courses
Building
- Set up a static website with Amplify
- Interact with an external API from your static website
- Get started with a deployment framework
- Build a Lambda function that's invoked by API Gateway
- Build a Lambda function that's invoked by EventBridge Scheduler
- Build a Lambda function that processes and saves files in S3
- Build a Lambda function that writes to DynamoDB
- Build a multi-step workflow with Step Functions
Courses
I'm a big fan of hands-on learning through building your own projects, but beginning with a learning course can be helpful to understand the core concepts and how it all fits together. These two are both available for free on AWS Skill Builder.
Cloud Essentials Learning Plan
If you're new to cloud, the Cloud Essentials Learning Plan is a great course to start with. This course gives you a foundational understanding of cloud concepts.
Serverless Learning Plan
If you're familiar with cloud but new to building with serverless, the Serverless Learning Plan will take you through the core serverless services.
Building
I found that I learned best by starting small and steadily adding in more services, increasing the complexity of my applications over time. The guide below starts with simple static websites. It then introduces some of the most common patterns in serverless applications. By the end, you'll be able to build an application that uses Amplify, Lambda, API Gateway, EventBridge, Step Functions, S3, 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 with Amplify
A good place to start is hosting a static website with Amplify. You can do so by uploading a HTML file with just few lines of code, like this:
<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 with Amplify!</p>
</body>
</html>
You can drag and drop a file into Amplify:
Or, you can connect Amplify to a version control system, like a GitHub repository:
Amplify also gives you an easy way to add a custom domain name for your static website:
- Tutorial: Add a custom domain managed by Amazon Route 53
- 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. To get started working with APIs, I found it useful to first practice calling an existing API before building my own API. You can add the JavaScript files to your existing static website hosted with Amplify.
Tutorial: How to Connect to an API with JavaScript
Example project: This Magic: The Gathering card finder app pulls Magic card data from the Scryfall Magic API.
3. Get started with a deployment framework
Next up is starting to build the backend application, and a serverless deployment framework will come in handy.
The AWS Console is a great place to explore new services, but as you start building and your application grows with more resources, it can become easy to forget what code or configuration changes you've made. A serverless deployment framework lets you define and deploy all of the resources in your application as infrastructure as code. By defining your application with a framework, you know exactly what you're deploying each time. You can also save and review your application definition in a version control system like GitHub. This makes building complex applications much easier to manage.
I use the Serverless Application Model (SAM). SAM also has a SAM CLI tool to deploy your application that the next tutorial uses. There are a few other framework options like Serverless Framework and Terraform.
Here is an example of defining a Lambda function with SAM:
You can write your application definition with SAM manually, or you can use the Application Composer visual designer tool to drag-and-drop resources into your application. Application Composer will then export a SAM template for you.
For the rest of the guide, I've included SAM templates of my own or from the Serverless Land Patterns collection as examples.
4. Build a Lambda function that's invoked by API Gateway
Here you'll build your first Lambda function and invoke it through API Gateway. Your Lambda function will be invoked every time you call your API endpoint.
Example project: This is a random greeting generator that also calls an external weather API. The webpage URL accepts query string parameters to show the weather for any location, with Seattle as the default - London, Tokyo, Dubai. A Lambda function is invoked by API Gateway when a user hits the page. The function pulls the random greeting (and random font color) from S3, calls the weather API, and generates the page's HTML. Check out the source code here.
5. Build a Lambda function that's invoked by EventBridge Scheduler
Another way to trigger a Lambda function is to create an EventBridge scheduled event that will invoke your function on a schedule (ex, once a week, once a minute).
Tutorial: Schedule AWS Lambda Functions Using Eventbridge Scheduler
Example project: I built an application that sends daily Chinese vocab to subscribers. The first version of this application was simply a daily EventBridge scheduled event and a Lambda function that sent vocabulary emails to subscribers. You can read more in this blog post on it.
6. Build a Lambda function that processes and saves files in S3
You can use Simple Storage Service (S3) to store objects like text, image, and audio files. When an object is uploaded or changed in S3, S3 emits an event that can invoke a Lambda function. Lambda functions can also interact with S3 files. You can learn more about this pattern in this video.
7. Build a Lambda function that writes to DynamoDB
DynamoDB is a database that's optimized for use with serverless applications. You can use it to store data, like frequently changing data about your application's users. This DynamoDB core components guide is a great read to start with.
Tutorial: Create a Serverless Application with AWS Lambda and DynamoDB
Pattern: Persist an item to a DynamoDB table from a Lambda function
Example project: I added a DynamoDB table into my Chinese language learning app once I started needing to manager users and keep track of the lists they're subscribed to. Check out this blog post for details.
8. Build a multi-step workflow with Step Functions
With Step Functions, you can build workflows with AWS services. A workflow can include components like branching logic, looping over an array, or waiting for a human approval step. Step Functions also has a visual builder tool, Workflow Studio, that you can use to design workflows and export infrastructure-as-code. Step Functions workflows are defined in Amazon States Language which you can deploy as part of your SAM template (tutorial).
Tutorial: Create a Step Functions state machine using AWS SAM
Example project: I used a Step Functions workflow to generate audio files for my Chinese language learning application. The workflow retrieves the vocabulary list from DynamoDB and loops through the words. It generates audio files with Amazon Polly and saves the files to S3. You can check out this blog post on it.
Starting with these components - Amplify, Lambda, API Gateway, EventBridge, S3, DynamoDB, and Step Functions - and a few common patterns, there are endless possibilities of applications that you can build.
Happy building!
🐿️