Changing the Domain name of the API endpoint without subdirectories


#1

I have managed to move a static website to rubyonjets and it deploys great onto lambda with an api endpoint like such XXXXXXX.execute-api.ap-southeast-1.amazonaws.com/prod
I need now to configure Route 53 to point my domain to this endpoint via a CNAME or A record but am unable to do so because the endpoint has a subdirectory “/prod” on it.
Am reading the documentation and it looks like I am supposed to specify on the application.rb
config.domain.hosted_zone_name = “mydomain”
config.domain.name = “mydomain”
config.domain.cert_arn = “certkey generated by Amazon Certificate Manager”

I tried deploying and it failed with the message “Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to create: [DomainName]”

Please someone tell me I am missing something crucial in my understanding.


#2

Ahhh! So I have managed to get the custom domain to work by setting
config.domain.hosted_zone_name = “mydomain”
config.domain.name = “www.mydomain”

The domain.name parameter seems to require a subdomain. So now the static page works quite well with the www prefix but will not work without it which is a step closer but still not great. Anyone know how I can:

  1. make it work without the www prefix
  2. do a redirect for www.mydomain to mydomain

#3

So I managed to fix this and I think its a bug that needs to be tested on Jets.
When you set the config.domain.name jets automatically creates a API Gateway - Custom Domain Name mapping between the named domain (eg: www.mydomain) to the API Gateway endpoint.
Then on Route 53, it creates an Alias record between the domain and the API Gateway endpoint.
All good.

So I saw the Custom domain mapping for www.mydomain and I added another one similar for the root domain “mydomain” and it started working.

So Jets doesn’t allow using the root domain name at config.domain.name but AWS doesn’t seem to care. I will look into the source to see why this is happening and propose a fix if I am able.