DEV Community

Cover image for Link  your sub-domain to AWS API Gateway
Paul Allies
Paul Allies

Posted on • Edited on

5 2

Link your sub-domain to AWS API Gateway

Let's hook up the name myapp.nanosoft.co.za to an AWS API Gateway

Create Certificate for Domain

  • Go to the Certificate Manager console
  • Request a certificate
  • Select "Request a public certificate"
  • Add one or more domain names, in my case I add myapp.nanosoft.co.za
  • Choose DNS validation
  • You'll be given a CNAME entry to which you'll need to register at your DNS Registrar e.g:
HOST: _xxxxxxxxxxxxxxxxxxxxx.myapp.nanosoft.co.za 
TYPE: CNAME
VALUE: _xxxxxxxxxxxxxxxx.xxxxxxxxx.acm-validations.aws.
Enter fullscreen mode Exit fullscreen mode

This is necessary to validate that you own the subdomain

  • Test the DNS Validation registration with
$> dig +short _xxxxxxxxxxxxxxxxxxxxx.myapp.nanosoft.co.za
Enter fullscreen mode Exit fullscreen mode

you should get a response of

_xxxxxxxxxxxxxxxx.xxxxxxxxx.acm-validations.aws.
Enter fullscreen mode Exit fullscreen mode
  • Once AWS has found this validation token, you'll notice that the certificate manager will update the status of the certificate from "Pending" to "Issued". Next, let's create an API Custom Domain record

Create a custom Domain

  • Go to the API Gateway console
  • Go to Custom domain names and create a domain name
    1. Choose TLS 1.2
    2. Regional Endpoint
    3. Choose the newly created Certificate for myapp.nanosoft.co.za
    4. Click "Create Domain Name"

Link the Domain Name to Rest API

  • Go to the API Gateway console
  • Go to Custom domain names
  • Select myapp.nanosoft.co.za
  • Configure the API mapping by choosing an API and Stage, Path is optional
  • Save mapping

Link the Domain Name to Rest API

  • Go to the Route 53 console
  • Create a Hosted Zone, In my case it would be nanosoft.co.za
  • Create an A Record for a subdomain by choosing Simple Routing
  • add the subdomain myapp to the existing nanosoft.co.za domain
  • Choose "A record"
  • For Value/Route to, choose "Alias to API Gateway API"
  • Choose the region where the api exists, in my case af-south-1
  • Choose the matching API gateway, e.g. d-xxxxxx.execute-api.af-south-1.amazonaws.com
  • Click "Define simple record"
  • Now that you have this A Record, we need a CNAME in our DNS to link the subdomain. Do so by adding a CNAME record at your DNS Registrar
Host: myapp, //or myapp.nanosoft.co.za depending on your DNS Registrar 
Type: CNAME, 
Value: d-xxxxxx.execute-api.af-south-1.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry 🕒

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay