google_compute_region_target_http_proxy

Represents a RegionTargetHttpProxy resource, which is used by one or more forwarding rules to route incoming HTTP requests to a URL map.

To get more information about RegionTargetHttpProxy, see:

Open in Cloud Shell

Example Usage - Region Target Http Proxy Basic

resource "google_compute_region_target_http_proxy" "default" {
  region  = "us-central1"
  name    = "test-proxy"
  url_map = google_compute_region_url_map.default.id
}

resource "google_compute_region_url_map" "default" {
  region          = "us-central1"
  name            = "url-map"
  default_service = google_compute_region_backend_service.default.id

  host_rule {
    hosts        = ["mysite.com"]
    path_matcher = "allpaths"
  }

  path_matcher {
    name            = "allpaths"
    default_service = google_compute_region_backend_service.default.id

    path_rule {
      paths   = ["/*"]
      service = google_compute_region_backend_service.default.id
    }
  }
}

resource "google_compute_region_backend_service" "default" {
  region                = "us-central1"
  name                  = "backend-service"
  protocol              = "HTTP"
  timeout_sec           = 10
  load_balancing_scheme = "INTERNAL_MANAGED"

  health_checks = [google_compute_region_health_check.default.id]
}

resource "google_compute_region_health_check" "default" {
  region = "us-central1"
  name   = "http-health-check"
  http_health_check {
    port = 80
  }
}
Open in Cloud Shell

Example Usage - Region Target Http Proxy Https Redirect

resource "google_compute_region_target_http_proxy" "default" {
  region  = "us-central1"
  name    = "test-https-redirect-proxy"
  url_map = google_compute_region_url_map.default.id
}

resource "google_compute_region_url_map" "default" {
  region          = "us-central1"
  name            = "url-map"
  default_url_redirect {
    https_redirect = true
    strip_query    = false
  }
}

Argument Reference

The following arguments are supported:


Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

RegionTargetHttpProxy can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import RegionTargetHttpProxy using one of the formats above. For example:

import {
  id = "projects/{{project}}/regions/{{region}}/targetHttpProxies/{{name}}"
  to = google_compute_region_target_http_proxy.default
}

When using the terraform import command, RegionTargetHttpProxy can be imported using one of the formats above. For example:

$ terraform import google_compute_region_target_http_proxy.default projects/{{project}}/regions/{{region}}/targetHttpProxies/{{name}}
$ terraform import google_compute_region_target_http_proxy.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_region_target_http_proxy.default {{region}}/{{name}}
$ terraform import google_compute_region_target_http_proxy.default {{name}}

User Project Overrides

This resource supports User Project Overrides.