How to get a Serverless web app working with your own domain and SSL on AWS, the right way

8 min readNov 15, 2020

Recently, I built a very simple CMS software to serve as the engine for my website La Siesta Americana (literally The American Siesta, like The American Dream but lazier). Why to build a CMS in 2020? There’s actually little or no reason, but I wanted to publish my content and literally no option in the market satisfied me, so I built my own for fun and to make a statement: we need no complex services, no plugins, no templating engines, no databases to publish content.

When my good friend and business partner Pedro saw it working, suggested that I published the software, and named it “Siesta” or similar, and here we are, ten hours later. I thought a CMS worth of its name needed to be shown in action, so I decided to use it to build its own product website.

The application is based on the Serverless framework, and I wanted to deploy it to my AWS account using a custom domain, with HTTP to HTTPS redirection that worked both for the www domain and the naked version (the one with no www). So, in other words:,, all needed to redirect to seamlessly.

My final setup

I also wanted two subdomains: to host the development stage, and to host the production one. would replicate or act as an alias for the production subdomain. The naked domain will just redirect to www, but I wanted such redirection to work for both HTTP and HTTPS.

If you’ve played around with AWS CloudFront you know that was going to be an epic battle.

The ultimate step-by-step guide

Since this was more complex than I first thought, I want to share my struggle so humanity won’t solve this problem more than once. This guide will walk you through the process I followed.

First, create your app

I used Serverless framework to build my service. You can check out the code on GitHub if you want to use it as a template. I’ll be using it as a reference to make my instructions a bit easier to understand.

Create your domain and setup a…


I’ve been into software engineering for the most part of my life so I have thought long and hard about it. Now I‘m just writing it down.