It’s hard to convey how big a fan of GCP Cloudrun I am. We started using it as a testing ground for APIs before “promoting” them to Kubernetes, however now we’re keeping production services on Cloudrun, and basking in it’s minimal overhead and flexibility.
With that in mind we’re migrating over services from AWS, which means mapping existing Route 53 zones over to Cloudrun. Here’s our guide.
In this case we need to map “api.theAnalyticsapi.com” to an existing Cloudrun service called “tanalytics-collector-api”
Step 1. Cloudrun -> Manage Custom Domains
Step 2. Click “Add Mapping”
Step 3. Select your service, “Verify a new domain” and add the base domain (the Route 53 Zone) – in my case “theanalyticsapi.com”
Step 4. We now need to prove to Google that we own the domain, so click “Verify in webmaster Central” which will open the Webmaster page in a new tab.
Step 5. Select “Other” as the provider, then copy the “google-site-verification….” line
Step 6. In a new browser Tab – Open the Zone in AWS Route 53
Step 7. Click “Create Record”, and add a TXT record using the “google-site-verification…” link
Step 8. Go back to Webmaster tab, and click “Continue Verification and Close” (for me this was instantaneous, however for some domains it may take some time for a TXT record to propagate)
Step 9. Go back to the original Cloudrun tab, and click “Add Mapping” again. Your domain should now be selectable in the list. Add the subdomain you wish to map, for me this was “api”
Step 10. Click “Continue” and copy the CNAME “ghs.googlehosted.com.”, and click “DONE”. This will a while to setup, so carry on with the AWS mapping.
Step 11. Go back to the Route 53 tab, and create a new CNAME record for the same subdomain
Step 12. Wait for the new CNAME to be setup and resolve in both platforms (usually under 20mins), then you should be able to use the new AWS Subdomain with your fancy Cloudrun service