Login to your Google Domains account
Under `My Domains`, select the domain to which you are going to create a subdomain.
In my example, lets consider we are going to create a subdomain called `example.api.stackmoments.com`.
Create ACM Certificate for your Sub Domain
- Login to your AWS account and go to AWS Certificate Manager service.
- Click on Request button to create a new certificate.
- Choose "Request a public certificate" as the Certificate Type.
- Fill the Fully qualified domain name field with your sub domain name. E.g., example.api.stackmoments.com
- Choose Validation method as DNS validation - recommended
- Choose the Key Algorithm like you wish and select Request.
Once certificate is requested, certificate status will change to pending validation. Until this has been validated by your DNS (stackmoments.com), this will be in same status.
By now, if you navigate into your certificate, you can see the generated CNAME name and CNAME value.
Perform DNS Validation
Go back to your Google Domains site.
Under Custom Records, click on Manage Records button and then click "Create new record".
Copy CNAME name and CNAME value from AWS Certificate Manager and enter in the Host name and Data respectively as shown below.
Wait for couple of hours for the DNS to perform the validation. Once it is validated, Certificate status in ACM will turn to success.
Create Custom Domain in Amazon API Gateway
Go to AWS Console and navigate to API Gateway service.
On the left side navigation, select Custom domain names and then click on Create button.
Provide your domain name, select TLS version as TLS 1.2, Endpoint configuration as Regional for Http API, and then
Select the ACM Certificate which has been created recently.
And click on Create domain name button.
Once Domain name is created, configure your API Mappings.
Link AWS API Gateway URL with Sub Domain Endpoint
Switch back to your Google Domains to create a new CNAME record.
Under host name, enter your sub domain and in the Data, add your API Gateway Endpoint.
Wait for couple of hours to migrate this change to happen. And then you are ready to consume your APIs using Custom Domain Name.
Comments
Post a Comment