I have an App Engine service called my-api
, and I wish to use a custom domain to point to this service. It looks straightforward enough to use a dispatch.yaml
file to perform the redirect to the service, but when I go to "Add a Custom Domain" in my App Engine settings, the last step asks me to add A records pointing to my root domain.
The problem is that I want to create a custom domain of the form
my-api.my-org-domain.com
But I don't want to divert traffic to
my-org-domain.com
which is a WordPress site. However, even when I remove the naked domain from the second step, the last step still requires me to change the IP address of my-org-domain.com
.
Is it possible to add a custom domain without changing the routing to my naked domain?
UPDATE
This has been asked before, and there is advice to only add the CNAME record at the end. However, the CNAME record points only to ghs.googlehosted.com
, and not to my App Engine service. When I only add the CNAME record, then a GET request to the subdomain gives
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /</pre>
</body>
</html>
Answering as a Community Wiki, so that it may help others too. @Rob Lyndon feel free to add if anything is not covered.
As @Badala Prashanth, shared a Stackoverflow Link which suggested
To map test.example.com to the existing project in GCP. Note that you do need to verify ownership of the subdomain. Then delete the existing mapping to that project. I did not update the domain custom resource records yet. I switched to the new project in GCP and mapped example.com to it. At the step (5) where it said update your domain records, I realized that the A and AAAA records for the 2 projects were exactly the same. This was confusing to me. What I realized is that GCP is doing some mapping to the correct project internally, it is not all a DNS thing. To update the DNS records I just left the existing DNS records that I already had and added A and AAAA records for test.example.com with the same values as the existing records. Of course it took a wile for all of the DNS and GCP mapping to flow through.