user16266293
user16266293

Reputation: 3

AWS Route53 hosted zones multiple records of type A

I registered a domain on Route53 and I would like to use the same domain for both my front-end and the back-end (example xyz.com).

The whole infrastructure is hosted on AWS.

I created a record of type A to point the API Gateway endpoints and I now try to create a new record of type A to serve the front-end (point cloudfront) which doesn't allow me, returning the error:

A record with the specified name already exists.

What is the correct way to achieve having both the front-end and the back-end behind the same domain?

Upvotes: 0

Views: 850

Answers (1)

Chuong Nguyen
Chuong Nguyen

Reputation: 1162

First of all, you can not create multiple A records like that.

As luk2302 said, the normal approach is use two domains. But if you want to keep the same domain for both FE and BE, you can use multiple path patterns of CloudFront to do the routing for you.

It will look like this: You have 1 CloudFront distribution, it will have 2 behaviors with 2 origins: S3 and API Gateway. The first behavior will have path pattern /api/* and it will point to API Gateway's Origin. And the default path pattern will go to S3's Origin

Upvotes: 2

Related Questions