Setting Up a Domain Through AWS Route 53 for a Django App

Walk through of the necessary steps

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

This lesson preview is part of the Serverless Django with Zappa course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to Serverless Django with Zappa, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Serverless Django with Zappa
  • [00:00 - 00:08] All right, let's get started with activating your domain. I'm going to assume that using AWS services, if you're not using AWS, we'll talk a little bit about the process in the next lesson.

    [00:09 - 00:14] First step is to get a registered domain. I've done it here using AWS Route 53.

    [00:15 - 00:23] Next, I need to create a hosted zone. If you registered your domain through AWS, you will automatically create a hosted zone for you.

    [00:24 - 00:28] I'm going to go ahead and create one now. Just type in your domain name here.

    [00:29 - 00:35] I'll go ahead and create a hosted zone. That was easy.

    [00:36 - 00:40] Now we're going to create a secure certificate. We're going to need to find ACM.

    [00:41 - 00:46] ACM stands for Amazon Certificate Manager. It will create an SSL TLS certificate for us.

    [00:47 - 00:50] This is what we need to do. We're going to create a secure certificate.

    [00:51 - 00:52] We're going to create a secure certificate. We're going to need to find ACM.

    [00:53 - 00:57] ACM stands for Amazon Certificate Manager. It's a TLS certificate for us.

    [00:58 - 01:07] This is what we need for our client browsers to create a secure connection to our website. An important note here is that you have to do this step in the Northern Virginia region.

    [01:08 - 01:16] If you don't, it's not going to work properly. Even if your Zappa project is in another region, you'll have to do this particular step in US East One.

    [01:17 - 01:24] For our ACM certificate, just scroll down and click Get Started. You should be on the Requested Certificate page.

    [01:25 - 01:32] We're requesting a public certificate. Here we add the main names.

    [01:33 - 01:39] You can put multiple domain names here. You have to put at least one.

    [01:40 - 01:53] For this domain name, I'm going to put dub dub dub dot zappaguide dot com in addition to the bare or apex root domain of zappaguide dot com. This will give us flexibility later.

    [01:54 - 02:00] If we ever want to use dub dub dub in addition to zappaguide dot com. Once that's filled in, go ahead and hit Next.

    [02:01 - 02:06] The next step is used to prove that you have ownership of the domain. There are multiple ways of doing this.

    [02:07 - 02:20] You can either have a DNS validation or email validation. If you're using the hosted zone in Route 53, DNS validation is going to be the easiest and quickest way to validate that you own this address.

    [02:21 - 02:28] So let's select that one. DNS validation requires you to make special DNS changes to prove that you have full control over the domain name.

    [02:29 - 02:33] We're not going to use tags at this point. We're reviewing the information we put in here.

    [02:34 - 02:40] All looks good, so we're going to confirm and request. But this point validation is required.

    [02:41 - 02:49] Fortunately, since we're using Route 53, Amazon makes this very easy. I simply have to open up each of those domain names.

    [02:50 - 03:01] And it tells me I need to make a DNS record with this value in it. It has a shortcut here that enables Route 53 to automatically create this record for me.

    [03:02 - 03:06] So I'm going to use that. I need to confirm that I'm going to make this record.

    [03:07 - 03:13] Now I've done that for zappaguide.com. I also have to do it for dub dub dub zappaguide.com.

    [03:14 - 03:19] And I follow the same steps here to have it create the records. Pretty easy, huh?

    [03:20 - 03:33] It says it may take up to 30 minutes for the changes to propagate, but in my experience, this is actually a pretty quick process. We can see here that a request is pending validation.

    [03:34 - 03:45] We're going to give it a few minutes to finish. Okay, now that Amazon has issued our certificate, we're going to associate this certificate with our zappa project.

    [03:46 - 03:57] If you open this up and scroll down, you'll see that there's an ARN, which is an Amazon resource number, a big, long number. We're going to need that.

    [03:58 - 04:04] First, let's go to zappasettings.json. And we're going to add a few more keys to our file here.

    [04:05 - 04:15] You notice we're adding a key certificate ARN, and we're also adding domain. Our domain is going to be zappaguide.com.

    [04:16 - 04:23] And the ARN, I'm going to cut and paste from the Amazon console. Now that that's saved, let's go to our shell.

    [04:24 - 04:37] We're going to use a new zappa utility command called certify. This will associate our domain name with our zappa project.

    [04:38 - 04:50] It's going to ask us if we're sure we want to certify, we're going to say yes, and hit continue. At this point, zappa has requested to Amazon to associate the certificate with our zappa project.

    [04:51 - 04:58] As you can see by the warning here, this could take a significant amount of time to accomplish. So let's be patient for this one.

    [04:59 - 05:15] To check to see if certify is complete, we can go to the website, create a new tab, and just type in the name, and it's working now. However, we get an error. Once again, we run into the Django security feature.

    [05:16 - 05:36] Now it's telling us that zappaguide.com is not a properly registered host that can be used for this website. So we simply have to go back to our settings file, scroll up to allow hosts, and now we can add. Now we can add zappaguide.com.

    [05:37 - 05:45] We'll save this. One more thing we have to do. Since I'm using white noise, I'm going to change my static error out to just be slash static.

    [05:46 - 05:51] And now let's do a quick update. Okay, that's done. Let's check our website now.

    [05:52 - 06:00] I'm going to refresh. That is working great. And if I check the admin site, I see the static files are working as well.

    [06:01 - 06:06] That's it for this lesson. In the next lesson, we're going to look at some corner cases if you're not using Amazon.