Google Compute Engine URL Map

This page shows how to write Terraform for Compute Engine URL Map and write them securely.


Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.


Terraform Example (google_compute_url_map)

UrlMaps are used to route requests to a backend service based on rules that you define for the host and path of an incoming URL. To get more information about UrlMap, see:


  • creation_timestamp requiredcomputed - string
    • Creation timestamp in RFC3339 text format.

  • default_service optional - string
    • The backend service or backend bucket to use when none of the given rules match.

  • description optional - string
    • An optional description of this resource. Provide this property when you create the resource.

  • fingerprint requiredcomputed - string
    • Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking.

  • id optionalcomputed - string
  • map_id requiredcomputed - number
    • The unique identifier for the resource.

  • name required - string
    • Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression 'a-z?' which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

  • project optionalcomputed - string
  • self_link requiredcomputed - string

Example Usage (from GitHub)

resource "google_compute_url_map" "web_https" {
  provider        = google
  name            = "web-url-map-https"
  default_service = google_compute_backend_bucket.static_site.self_link

resource "google_compute_url_map" "http" {
  name    = local.HTTP_URLMAP_NAME
  project = data.google_project.primary.number
  default_url_redirect {
    https_redirect         = true
    redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
resource "google_compute_url_map" "main" {
  name            = "gaup"
  default_service = google_compute_backend_bucket.main.self_link

resource "google_compute_managed_ssl_certificate" "main" {
resource "google_compute_url_map" "marketing_site_https" {
  name        = "marketing-site-https-url-map"
  description = "URL Map for the Remarkable Sidekick Marketing Page"

  default_service =

Frequently asked questions

What is Google Compute Engine URL Map?

Google Compute Engine URL Map is a resource for Compute Engine of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Compute Engine URL Map?

For Terraform, the MatthewCYLau/react-serverless-gcp-terraform, kennedycmr/terraform-google-cloudrun-public-byo-domainname and rdeknijf/github-actions-upgrader source code examples are useful. See the Terraform Example section for further details.