Tuesday, April 2, 2024

AWS Custom Domain Name with API Gateway for REST APIs

     Imagine have a setup in Lambda similar to an api endpoint. But still you have to access and called to that api endpoint via the given endpoint name by AWS. 

Will you like to call to that endpoint from a subdomain what ever you like ? YES it is possible. Let's have a look on the implementation of this setup.

Below is the architectural diagram of the design of what we need to achieve. So the user should be able to call a sub domain such as {stage}.{aws-region}.api.{yourdomain}

                                         


As highlighted you have to use AWS Route 53,API Gateway, ACM and Lambda in order to proceed with the above setup.

First you have go to the AWS AWS Certificate manager and create a certificate for the desired subdomain. Here -> {stage}.{aws-region}.api.{yourdomain} .Set the verification with DNS or Email and you will get the notification to approve the Certificate Request (Only if you are the owner of the domain)


Then We are ready with the certificate and now let's create a custom domain name in API Gateway

Add a mapping with your Lambda


Now we are done with the basic setting. You need to create a record in the hosted zone to load your api gateway when domain called.


Finally as you are done with above all, you can use POSTMAN and call to the endpoint which you created.




No comments:

Post a Comment