DEV Community

Cheedge Lee
Cheedge Lee

Posted on

Setting Up Custom Domain for API Gateway & CloudFront

During migrating one local host website to AWS, there are many point I need to write donw. Each article will be a short note, just keep as simple as possible to record the working steps, which makes it later can be quickly found, and also with a simple description. Therefore this serie will not be a detailed explain articles.

Preparing certificate

First we need the SSL/TLS cert, and how to apply it on AWS ACM can be found here.

CloudFront

API Gateway

  1. In API Gateway console click the custom domain names, add a domain name.
  2. Fill in the domain (subdomain) name same as the domain name in the certificate you apply before.
  3. Refresh the ACM certificate, and choose the one used for the domain name you filled in before, and add.
    • it will provide a API Gateway domain name, which used in next step, copy it.
  4. Next, go to the Domain Dashboard where you register your domain (eg. cloudflare), and create a new CNAME record.
    • The name for this record is your domain(subdomain).
    • the Target should be above copied new generated API Gateway domain name.
    • (option) in cloudflare make sure that SSL encryption Mode be Full or Full(strict)
  5. API Gateway Mapping.
    • under the Custom domain names -> your created domain name -> config API Gateway Mapping.
    • Select the API and the Stage. for me, it's BackendAPI and prod Stage. Then when I use this domain, I can not add prod as a path after the domain.

Top comments (0)