2015-10-30 20:34:14 +00:00
---
layout: "google"
page_title: "Google: google_compute_global_forwarding_rule"
2016-04-10 21:34:15 +00:00
sidebar_current: "docs-google-compute-global-forwarding-rule"
2015-10-30 20:34:14 +00:00
description: |-
Manages a Target Pool within GCE.
---
# google\_compute\_global\_forwarding\_rule
2016-04-10 21:34:15 +00:00
Manages a Global Forwarding Rule within GCE. This binds an ip and port to a target HTTP(s) proxy. For more
2015-10-30 20:34:14 +00:00
information see [the official
2017-03-08 18:17:18 +00:00
documentation](https://cloud.google.com/compute/docs/load-balancing/http/global-forwarding-rules) and
2015-10-30 20:34:14 +00:00
[API ](https://cloud.google.com/compute/docs/reference/latest/globalForwardingRules ).
## Example Usage
2017-04-17 10:17:54 +00:00
```hcl
2015-10-30 20:34:14 +00:00
resource "google_compute_global_forwarding_rule" "default" {
2017-10-31 18:28:55 +00:00
name = "default-rule"
2016-04-10 21:34:15 +00:00
target = "${google_compute_target_http_proxy.default.self_link}"
port_range = "80"
2015-10-30 20:34:14 +00:00
}
resource "google_compute_target_http_proxy" "default" {
2016-04-10 21:34:15 +00:00
name = "test-proxy"
description = "a description"
url_map = "${google_compute_url_map.default.self_link}"
2015-10-30 20:34:14 +00:00
}
resource "google_compute_url_map" "default" {
2016-04-10 21:34:15 +00:00
name = "url-map"
description = "a description"
default_service = "${google_compute_backend_service.default.self_link}"
2015-10-30 20:34:14 +00:00
2016-04-10 21:34:15 +00:00
host_rule {
hosts = ["mysite.com"]
path_matcher = "allpaths"
}
2015-10-30 20:34:14 +00:00
2016-04-10 21:34:15 +00:00
path_matcher {
name = "allpaths"
default_service = "${google_compute_backend_service.default.self_link}"
2017-02-18 22:48:50 +00:00
2016-04-10 21:34:15 +00:00
path_rule {
paths = ["/*"]
service = "${google_compute_backend_service.default.self_link}"
2015-10-30 20:34:14 +00:00
}
2016-04-10 21:34:15 +00:00
}
2015-10-30 20:34:14 +00:00
}
resource "google_compute_backend_service" "default" {
2016-04-10 21:34:15 +00:00
name = "default-backend"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
2015-10-30 20:34:14 +00:00
2016-04-10 21:34:15 +00:00
health_checks = ["${google_compute_http_health_check.default.self_link}"]
2015-10-30 20:34:14 +00:00
}
resource "google_compute_http_health_check" "default" {
2016-04-10 21:34:15 +00:00
name = "test"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
2015-10-30 20:34:14 +00:00
}
```
## Argument Reference
The following arguments are supported:
2016-04-10 21:34:15 +00:00
* `name` - (Required) A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
2015-10-30 20:34:14 +00:00
2016-04-10 21:34:15 +00:00
* `target` - (Required) URL of target HTTP or HTTPS proxy.
2015-10-30 20:34:14 +00:00
2016-04-10 21:34:15 +00:00
- - -
2015-10-30 20:34:14 +00:00
2016-04-10 21:34:15 +00:00
* `description` - (Optional) Textual description field.
* `ip_address` - (Optional) The static IP. (if not set, an ephemeral IP is
2017-04-26 22:52:49 +00:00
used). This should be the literal IP address to be used, not the `self_link`
2017-09-11 17:09:07 +00:00
to a `google_compute_global_address` resource. (If using a `google_compute_global_address`
2017-04-26 22:52:49 +00:00
resource, use the `address` property instead of the `self_link` property.)
2016-04-10 21:34:15 +00:00
* `ip_protocol` - (Optional) The IP protocol to route, one of "TCP" "UDP" "AH"
"ESP" or "SCTP". (default "TCP").
2015-10-30 20:34:14 +00:00
* `port_range` - (Optional) A range e.g. "1024-2048" or a single port "1024"
2016-04-10 21:34:15 +00:00
(defaults to all ports!).
2018-01-03 21:21:45 +00:00
Some types of forwarding targets have constraints on the acceptable ports:
* Target HTTP proxy: 80, 8080
* Target HTTPS proxy: 443
* Target TCP proxy: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222
* Target SSL proxy: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222
* Target VPN gateway: 500, 4500
2015-10-30 20:34:14 +00:00
2018-03-12 20:59:47 +00:00
* `project` - (Optional) The ID of the project in which the resource belongs. If it
2016-04-10 21:34:15 +00:00
is not provided, the provider project is used.
2015-10-30 20:34:14 +00:00
2017-09-25 22:16:54 +00:00
* `ip_version` - (Optional)
2017-08-10 20:28:52 +00:00
The IP Version that will be used by this resource's address. One of `"IPV4"` or `"IPV6"` .
2018-06-05 20:39:40 +00:00
You cannot provide this and `ip_address` .
2017-08-04 17:15:51 +00:00
2017-09-25 22:16:54 +00:00
- - -
2018-10-08 18:14:08 +00:00
* `labels` - (Optional)
2018-10-04 20:20:35 +00:00
A set of key/value label pairs to assign to the resource. This property is in beta, and should be used with the terraform-provider-google-beta provider.
2018-10-09 15:21:19 +00:00
See [Provider Versions ](https://terraform.io/docs/providers/google/provider_versions.html ) for more details on beta fields.
2017-09-12 15:06:40 +00:00
2015-10-30 20:34:14 +00:00
## Attributes Reference
2016-04-10 21:34:15 +00:00
In addition to the arguments listed above, the following computed attributes are
exported:
2015-10-30 20:34:14 +00:00
2016-04-10 21:34:15 +00:00
* `self_link` - The URI of the created resource.
2017-09-12 15:06:40 +00:00
2018-10-08 18:14:08 +00:00
* `label_fingerprint` - The current label fingerprint. This property is in beta, and should be used with the terraform-provider-google-beta provider.
2018-10-09 15:21:19 +00:00
See [Provider Versions ](https://terraform.io/docs/providers/google/provider_versions.html ) for more details on beta fields.
2017-10-31 18:28:55 +00:00
## Import
Global forwarding rules can be imported using the `name` , e.g.
```
$ terraform import google_compute_global_forwarding_rule.default default-rule
2018-03-12 20:59:47 +00:00
```