How to attach custom domain names to an AWS API gateway?

How to attach custom domain names to an AWS API gateway?

November 18, 2020 / Nirav Shah

What is API Gateway?

As per Amazon definition “API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale.” APIs act as the “front door” for applications to access data, business logic, or functionality from your backend services. Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications. API Gateway supports containerized and serverless workloads, as well as web applications.

How to attach custom domain names to an API gateway?

Pre-Requirements

  • API gateway access
  • Domain name/Subdomain name

Step 1

As you can see we have created an API-gateway which is invoked in postman and is working

how-to-attach-custom-domain-names-to-an-api-gateway

Create an ACM certificate for the domain name which should be attached to the API-Gateway

Step 2

  • Open ACM in AWS console and click on Request a certificate
  • Select Request a Public Certificate

how-to-attach-custom-domain-names-to-an-api-gateway

Step 3

  • Add a domain name to your certificate which is to be attached in the API-Gateway
  • Click on Next

how-to-attach-custom-domain-names-to-an-api-gateway

Step 4

  • Select the validation method by which you have to validate your domain certificate
  • Click on Next

how-to-attach-custom-domain-names-to-an-api-gateway

Step 5

  • Add a Tag
  • Click on Next

how-to-attach-custom-domain-names-to-an-api-gateway

Step 6

  • Review the details
  • Click on Confirm and request

how-to-attach-custom-domain-names-to-an-api-gateway

Step 7

  • To validate your certificate via DNS you need to a CName record in the Route 53
  • In our case, we have used Cpanel but the process is the same

how-to-attach-custom-domain-names-to-an-api-gateway

Create a CName recordset

Step 8

  • Copy the recordset from AWS console and paste it in the Route 53
  • If you are using AWS set the TTL to 1

how-to-attach-custom-domain-names-to-an-api-gateway

Step 9

  • Once you have created the recordset click on continue

how-to-attach-custom-domain-names-to-an-api-gateway

  • After some time you will the status issued the certificate and your certificate is ready to be used

how-to-attach-custom-domain-names-to-an-api-gateway

Create a Custom Domain Name

Step 10

  • Navigate to the API-Gateway from AWS console

how-to-attach-custom-domain-names-to-an-api-gateway

Step 11

  • Click on Custom Domain Name on the left side of the AWS Console

how-to-attach-custom-domain-names-to-an-api-gateway

Step 12

  • Click on create
  • Input the domain name
  • Keep the configuration as it is
  • Select the ACM Certificate
  • Click on Create

how-to-attach-custom-domain-names-to-an-api-gateway

Step 13

  • As you click on create it will bring you to Domain name details where you will see all the details and API Mappings
  • API Mapping is the most important this in this

how-to-attach-custom-domain-names-to-an-api-gateway

API Mapping

Step 14

  • Click on Configure API Mapping

how-to-attach-custom-domain-names-to-an-api-gateway

Step 15

  • Click on Add new mapping

how-to-attach-custom-domain-names-to-an-api-gateway

Step 16

  • As you can see in the image below this is used to map the domain to API and stage
  • Select the API gateway for which you want a custom domain name
  • Select the stage
  • You can define the path (Optional)

how-to-attach-custom-domain-names-to-an-api-gateway

Point the create custom domain name to the domain

Step 17

  • Copy the API Gateway domain name as we need to route the domain request to this domain which will be more clear in the next step

how-to-attach-custom-domain-names-to-an-api-gateway

Step 18

  • Again create a CName record and point the API gateway domain name to the domain or the subdomain name

how-to-attach-custom-domain-names-to-an-api-gateway

Conclusion

Step 19

  • Now as you can see when we hit the domain name with defining the path the API gives the same result as seen in step 1

how-to-attach-custom-domain-names-to-an-api-gateway

Also Read: AWS API Gateway – The Front Door for application access.

Service:Hire AWS Expert

 

Talk to AWS Certified Consultant

    Spread Love By Sharing:

    Let’s Talk About Your Needed AWS Infrastructure Management Services

    Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.

    • Swift Hiring and Onboarding
    • Experienced and Trained AWS Team
    • Quality Consulting and Programming
    Let’s Connect and Discuss Your Project