I have a custom domain setup in route53 and using rout53 as domain service provider. I have a static page hosted in aws s3 bucket which I am using as the home page of the site. In route53 I have mapped the aws s3 url to my custom domain by adding alias records as per this document.
I also have some lambda functions, which serves html pages on requests. Now I am trying to map the api endpoint of these lambda functions to my custom domain.
The flow is mainly like this, when the user hits the home website i.e. xyz.com
, the homepage is served from the s3 static site. When the user navigates to other page say xyz.com/products/productId
, the html is served from the lambda function. I am able to follow and do most of the steps for mapping api gateway endpoint to custom domain, but it's at adding DNS records I am facing the issue and getting the error A record with specified name already exists
, which is understandable as I have already added the A record
for routing to s3 bucket for my root domain.
My question is, can I add multiple records for the same type A in aws? Or is there other way to approach this problem?
CodePudding user response:
No, you can't do it this way. A DNS name can only resolve to one thing.
Instead, you could create a subdomain so that:
xyz.com
--> Amazon S3 bucketproducts.xyz.com
--> API Gateway
You could pass the productId
as a parameter (eg products.xyz.com/?productId=42
).