Commit 862b98bc authored by Jamie Tanna's avatar Jamie Tanna
Browse files

Blogument non-AWS hosted custom domain on API Gateway

Closes #1129.
parent 25e82659
Pipeline #507059265 passed with stages
in 6 minutes and 18 seconds
title: Adding a Non-AWS Hosted Custom Domain to an AWS API Gateway without CloudFront
description: How to set up a domain name for AWS API Gateway for a domain that isn't managed through AWS Route 53.
- blogumentation
- aws
date: 2022-04-01T15:37:30+0100
- ""
license_code: "Apache-2.0"
license_prose: "CC-BY-NC-SA-4.0"
image: ""
slug: "api-gateway-domain"
I run a number of services using the [Architect Framework](, which makes running services on AWS API Gateway really straightforward.
As I wanted slightly nicer URLs for my services, instead of the default API Gateway URLs, I wanted to attach custom domain name. However, one thing that I found a bit frustrating was that a lot of guides that folks have produced to do this require using CloudFront, and I didn't need CloudFront for my purposes.
I thought I should document how I've done it for anyone else going through this in the future.
Note that the screenshots below may come out of sync over time with AWS, but hopefully it will still remain similar enough this can be followed.
First, browse to the API Gateway console and click the `Custom domain names` link in the sidebar:
![Screenshot of the API Gateway console, showing several APIs, and on the left hand sidebar, a link to APIs, Custom domain names, and VPC links](
Next, we `Create` a new domain name, and specify the domain name we want. In my case, I'm setting up the domain name ``.
![Screenshot of the Custom domains name page, showing several domain names, and a Create button](
We need to set up a certificate in Amazon Certificate Manager (ACM) to provide us a secure means of interacting with our API Gateway. Because this is needed as part of the domain name process, we need to click `Create a new ACM certificate` and complete that process before returning.
When we do return, we'll then have a list of endpoints available in the Endpoint configuration box:
![A list of endpoints in a selection box when clicking the Choose a certificate option](
Once created, we can see the `API Gateway domain name`, shown below:
![Screenshot of the newly created domain name, showing the endpoint configuration, with a API Gateway domain name, and a tab for API mappings](
This domain name noted above is the domain that we need to CNAME, for instance:
; <<>> DiG 9.18.1 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20072
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
; EDNS: version: 0, flags:; udp: 512
; IN A
This is the most important part, I've often trialed using the API Gateway ID, instead of the domain name, which does not work.
Remember that we need to add the `API mapping`s, otherwise our traffic will not be routed to the right API:
![Screenshot of the empty API mappings page, before the API has been configured](
![Screenshot of the in-progress configuration for the API mapping](
Et voilà, we can successfully access our service on the domain!
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment