I have a primary domain www.example.com
setup in Route 53 on AWS.
I want to point subdomain1.example.com
to Google Cloud, specifically to an instance group running in Google Compute Engine.
Is this possible?
Yes, and this is a good design practice called nameservice delegation. The best approach is to delegate an entire subdomain for GCP, so let's use the domain example.com and gcp.example.com as the domain and subdomain.
This way Google will manage DNS for you rather than you updating A & CNAME records in route53 manually.
Overall this will take these steps (1) creating the gcp.example.com
zone in GCP (2) obtaining the NS records for gcp.example.com
(3) delegating NS
for gcp.example.com
to Google Cloud NS and then (4) Create the resource-level records (e.g. for a VM or appengine app) in GCP Cloud DNS.
(1) Creating the Zone in GCP
This can be done in the console under Network Services -> Cloud DNS
or the cloud shell. I favor the shell.
$ gcloud dns managed-zones create gcp-example --description="GCP Example Zone" \
--dns-name="gcp.example.com"
(2) Obtain the NS Records for the new Zone
Below is an example -- copy the ones specific to your NS
gcloud dns managed-zones describe gcp-example |grep -A5 nameServers
nameServers:
- ns-cloud-d1.googledomains.com.
- ns-cloud-d2.googledomains.com.
- ns-cloud-d3.googledomains.com.
- ns-cloud-d4.googledomains.com.
(3) Add the delegate NS record in AWS
create update.json (make sure the value records are correct):
{
"Comment": "CREATE/DELETE/UPSERT a record ",
"Changes": [{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "gcp.example.com",
"Type": "NS",
"TTL": 300,
"ResourceRecords": [ {"Value" : "ns-cloud-d1.googledomains.com."}, {"Value": "ns-cloud-d2.googledomains.com."},
{"Value" : "ns-cloud-d3.googledomains.com."}, {"Value": "ns-cloud-d4.googledomains.com."}]
}}]
}
HOSTED_ZONE_ID=XXXXXX
aws route53 change-resource-record-sets --hosted-zone-id=${HOSTED_ZONE_ID} --change-batch=file://./update.json
{
"ChangeInfo": {
"Status": "PENDING",
"Comment": "CREATE/DELETE/UPSERT a record ",
"SubmittedAt": "2019-02-27T23:43:35.327Z",
"Id": "/change/XXXXXX"
}
}
(4) In GCP Cloud DNS, create all of your gcp resource records under gcp.example.com
At this point, you can manage all of your GCP dns within GCP Cloud DNS. Go ahead and create vm1.gcp.example.com
or appengine1.gcp.example.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With