Bird
Raised Fist0
GCPcloud~30 mins

Custom domains in GCP - Mini Project: Build & Apply

Choose your learning style10 modes available
Configure a Custom Domain for a Google Cloud Run Service
📖 Scenario: You have deployed a web application on Google Cloud Run. Now, you want to make it accessible through your own custom domain instead of the default Cloud Run URL.
🎯 Goal: Set up a custom domain mapping for your Cloud Run service to make your app accessible via www.example.com.
📋 What You'll Learn
Create a dictionary called domain_mapping with keys domain and service and values 'www.example.com' and 'my-cloud-run-service' respectively.
Create a variable called project_id and set it to 'my-gcp-project'.
Write a function called create_domain_mapping that takes domain, service, and project_id as parameters and returns a dictionary with these keys and values.
Add a final line that calls create_domain_mapping with the values from domain_mapping and project_id and assigns the result to final_mapping.
💡 Why This Matters
🌍 Real World
Custom domains make your cloud-hosted applications look professional and easier to remember for users.
💼 Career
Cloud engineers often configure custom domains to route traffic to cloud services securely and reliably.
Progress0 / 4 steps
1
Create the initial domain mapping dictionary
Create a dictionary called domain_mapping with the keys 'domain' and 'service' and the exact values 'www.example.com' and 'my-cloud-run-service' respectively.
GCP
Hint

Use curly braces to create a dictionary with the specified keys and values.

2
Add the GCP project ID variable
Create a variable called project_id and set it to the string 'my-gcp-project'.
GCP
Hint

Assign the exact string to the variable project_id.

3
Write a function to create the domain mapping dictionary
Write a function called create_domain_mapping that takes three parameters: domain, service, and project_id. The function should return a dictionary with keys 'domain', 'service', and 'project' set to the corresponding parameter values.
GCP
Hint

Define a function with the specified name and parameters, returning a dictionary with the keys and values from the parameters.

4
Create the final domain mapping configuration
Add a line that calls create_domain_mapping with the values from domain_mapping['domain'], domain_mapping['service'], and project_id, and assign the result to a variable called final_mapping.
GCP
Hint

Call the function with the dictionary values and assign the result to final_mapping.

Practice

(1/5)
1. What is the primary purpose of setting up a custom domain in Google Cloud Platform (GCP)?
easy
A. To use your own website address instead of a default GCP URL
B. To increase the storage capacity of your GCP project
C. To enable automatic backups for your cloud resources
D. To create virtual machines with custom names

Solution

  1. Step 1: Understand what a custom domain is

    A custom domain lets you use your own website address instead of a generic cloud URL.
  2. Step 2: Identify the purpose in GCP context

    In GCP, custom domains help users access services with familiar URLs, improving branding and trust.
  3. Final Answer:

    To use your own website address instead of a default GCP URL -> Option A
  4. Quick Check:

    Custom domain = personal website address [OK]
Hint: Custom domain means your own website address, not default URL [OK]
Common Mistakes:
  • Confusing custom domain with storage or VM settings
  • Thinking it changes backup or machine names
  • Assuming it increases resource limits
2. Which DNS record type must you configure to point your custom domain to a Google App Engine service?
easy
A. MX record
B. TXT record
C. SRV record
D. CNAME record

Solution

  1. Step 1: Identify DNS record types for domain pointing

    CNAME records map a domain or subdomain to another domain name, commonly used for pointing to cloud services.
  2. Step 2: Match with Google App Engine requirements

    Google App Engine custom domains require CNAME records to link your domain to their service address.
  3. Final Answer:

    CNAME record -> Option D
  4. Quick Check:

    Point domain to service = CNAME record [OK]
Hint: Use CNAME to point domain to cloud service address [OK]
Common Mistakes:
  • Using MX records which are for email routing
  • Using TXT records meant for verification
  • Confusing SRV records which are for service location
3. Given this snippet configuring a custom domain in GCP App Engine, what will happen if the DNS is not properly set?
gcloud app domain-mappings create example.com --certificate-management=automatic
medium
A. The command will fail with a syntax error
B. The domain will be mapped but users cannot access the app via example.com
C. The app will be accessible immediately without DNS changes
D. The SSL certificate will not be issued

Solution

  1. Step 1: Understand domain mapping command effect

    The command creates a domain mapping and requests SSL certificate automatically.
  2. Step 2: Consider DNS role in accessibility

    If DNS records do not point to GCP, users cannot reach the app via the custom domain despite mapping.
  3. Final Answer:

    The domain will be mapped but users cannot access the app via example.com -> Option B
  4. Quick Check:

    Mapping without DNS update = no access [OK]
Hint: Mapping alone doesn't work without DNS pointing [OK]
Common Mistakes:
  • Assuming command fails without DNS
  • Thinking app is accessible immediately
  • Believing SSL won't issue without DNS
4. You tried to add a custom domain to your GCP App Engine app but received an error: "Domain ownership verification failed." What is the most likely cause?
medium
A. You did not add the required TXT record to your domain's DNS
B. You used an incorrect CNAME record type
C. Your App Engine app is not deployed
D. You forgot to enable billing on your GCP project

Solution

  1. Step 1: Understand domain ownership verification process

    GCP requires you to prove you own the domain by adding a TXT record to DNS.
  2. Step 2: Identify cause of verification failure

    If the TXT record is missing or incorrect, verification fails and domain cannot be added.
  3. Final Answer:

    You did not add the required TXT record to your domain's DNS -> Option A
  4. Quick Check:

    Missing TXT record = ownership verification fail [OK]
Hint: Verify domain by adding TXT record in DNS [OK]
Common Mistakes:
  • Confusing CNAME with TXT for verification
  • Assuming app deployment affects verification
  • Thinking billing status causes verification error
5. You want to serve your website on both example.com and www.example.com using GCP App Engine with HTTPS. Which setup correctly achieves this with minimal manual DNS management?
hard
A. Map both domains; create TXT records for SSL; manually upload certificates
B. Map only example.com in App Engine; create A record for www pointing to example.com IP; manually manage SSL
C. Map both domains separately in App Engine and create CNAME for www pointing to ghs.googlehosted.com; use automatic SSL
D. Map www.example.com only; create CNAME for example.com pointing to www; disable SSL

Solution

  1. Step 1: Understand domain mapping for root and www

    Both example.com and www.example.com need mapping to serve content on both URLs.
  2. Step 2: Use recommended DNS and SSL setup

    Google recommends CNAME for www to ghs.googlehosted.com and automatic SSL management for ease and security.
  3. Final Answer:

    Map both domains separately in App Engine and create CNAME for www pointing to ghs.googlehosted.com; use automatic SSL -> Option C
  4. Quick Check:

    Separate mapping + CNAME + auto SSL = best practice [OK]
Hint: Map both domains and use CNAME for www with auto SSL [OK]
Common Mistakes:
  • Using A record for www which is not recommended
  • Mapping only one domain and missing the other
  • Disabling SSL or managing certificates manually unnecessarily
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard