In previous articles, I’ve described how to deploy an application in AWS. A backend application in AWS Lambda using an API Gateway, and a frontend application in AWS S3 with AWS CloudFront.
But both solutions use the AWS auto-generated URL.
But, when I create an application, I want to use my own domain name. I want my application to use my own URL.
Buying a domain name can be done in several services, like AWS or Squarespace. But I won’t enter into the details of this.
What I will describe in this article is, after buying a domain name, how to apply it to my frontend and backend applications deployed in AWS.
SSL Certificate
All the domains used in AWS must be protected, and must use an SSL certificate. And must be located in the region us-east-1.
I have the AWS Certificate Manager where I can request a public certificate.

Once there, I indicate the URL to use for the SSL certificate. I can also change the algorithm used for the SSL certificate.

In my case, I requested a wildcard certificate. This allows me to protect many URLs with a single certificate.
The process of validation takes some days. After AWS approves my request, I need to add a CNAME record to my Domain Name service manager.

Once this step is done, AWS allows me to use the certificate on any service.
CloudFront Distribution
Both my frontend and backend use an AWS CloudFront distribution. The frontend uses AWS S3 as origin, and the backend uses AWS API Gateway as origin.
When configuring an AWS CloudFront Distribution, I can indicate an alternate domain name. By default, AWS CloudFront generates a random URL for my distribution. But now that I have an SSL certificate, I need to add an alternate domain name to use my own URL.

After the modification is done, my AWS CloudFront Distribution can use both the AWS URL and my own URL. But to use my own URL, I need one last step.
CNAM record
Now that my AWS CloudFront distributions accept an alternate domain name, I need to add a CNAME record to point the AWS CloudFront distribution to my domain name.
| Host | Type | Value |
|---|---|---|
| backend. | CNAME | abcdefghij.cloudfront.net |
| frontend. | CNAME | jihgfedcba.cloudfront.net |
The changes of the CNAME records may take some time depending on the platform used.
Once the records are live, I can use both my frontend and backend own URLs for my application.
Conclusion
Using a custom domain name for my application is a step to show a professional application. Using an SSL certificate is not only a metric for a professional application but also an additional security for my application.



Leave a comment