0
0
GCPcloud~30 mins

Custom domains in GCP - Mini Project: Build & Apply

Choose your learning style9 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
Need a 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
Need a 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
Need a 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
Need a hint?

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