2014-11-20 17:40:17 +00:00
|
|
|
---
|
|
|
|
layout: "google"
|
|
|
|
page_title: "Google: google_compute_forwarding_rule"
|
2015-10-23 14:10:41 +00:00
|
|
|
sidebar_current: "docs-google-compute-forwarding-rule"
|
2014-11-20 17:40:17 +00:00
|
|
|
description: |-
|
2017-04-25 20:03:36 +00:00
|
|
|
Manages a Forwarding Rule within GCE.
|
2014-11-20 17:40:17 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# google\_compute\_forwarding\_rule
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
Manages a Forwarding Rule within GCE. This binds an ip and port range to a target pool. For more
|
2014-11-20 17:40:17 +00:00
|
|
|
information see [the official
|
|
|
|
documentation](https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules) and
|
|
|
|
[API](https://cloud.google.com/compute/docs/reference/latest/forwardingRules).
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2016-12-09 02:05:48 +00:00
|
|
|
```tf
|
2014-11-20 17:40:17 +00:00
|
|
|
resource "google_compute_forwarding_rule" "default" {
|
2017-06-16 17:53:36 +00:00
|
|
|
name = "website-forwarding-rule"
|
2016-04-10 21:34:15 +00:00
|
|
|
target = "${google_compute_target_pool.default.self_link}"
|
|
|
|
port_range = "80"
|
2014-11-20 17:40:17 +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.
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
- - -
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-12-01 02:12:52 +00:00
|
|
|
* `backend_service` - (Optional) BackendService resource to receive the
|
|
|
|
matched traffic. Only used for internal load balancing.
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `description` - (Optional) Textual description field.
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `ip_address` - (Optional) The static IP. (if not set, an ephemeral IP is
|
|
|
|
used).
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `ip_protocol` - (Optional) The IP protocol to route, one of "TCP" "UDP" "AH"
|
2016-12-01 02:12:52 +00:00
|
|
|
"ESP" or "SCTP" for external load balancing, "TCP" or "UDP" for internal
|
|
|
|
(default "TCP").
|
|
|
|
|
|
|
|
* `load_balancing_scheme` - (Optional) Type of load balancing to use. Can be
|
|
|
|
set to "INTERNAL" or "EXTERNAL" (default "EXTERNAL").
|
|
|
|
|
2017-10-06 16:33:42 +00:00
|
|
|
* `network` - (Optional) Network name or self_link that the load balanced IP
|
|
|
|
should belong to. Only used for internal load balancing. If it is not
|
|
|
|
provided, the default network is used.
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `port_range` - (Optional) A range e.g. "1024-2048" or a single port "1024"
|
2016-12-01 02:12:52 +00:00
|
|
|
(defaults to all ports!). Only used for external load balancing.
|
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
|
2016-12-01 02:12:52 +00:00
|
|
|
|
2017-04-25 20:03:36 +00:00
|
|
|
* `ports` - (Optional) A list of ports (maximum of 5) to use for internal load
|
|
|
|
balancing. Packets addressed to these ports will be forwarded to the backends
|
|
|
|
configured with this forwarding rule. Required for internal load balancing.
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2018-03-12 20:59:47 +00:00
|
|
|
* `project` - (Optional) The ID of project in which the resource belongs. If it
|
2016-04-10 21:34:15 +00:00
|
|
|
is not provided, the provider project is used.
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `region` - (Optional) The Region in which the created address should reside.
|
|
|
|
If it is not provided, the provider region is used.
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-12-01 02:12:52 +00:00
|
|
|
* `subnetwork` - (Optional) Subnetwork that the load balanced IP should belong
|
|
|
|
to. Only used for internal load balancing. Must be specified if the network
|
|
|
|
is in custom subnet mode.
|
|
|
|
|
|
|
|
* `target` - (Optional) URL of target pool. Required for external load
|
|
|
|
balancing.
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
## Attributes Reference
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
In addition to the arguments listed above, the following computed attributes are
|
|
|
|
exported:
|
2014-11-20 17:40:17 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `self_link` - The URI of the created resource.
|
2017-06-16 17:53:36 +00:00
|
|
|
|
|
|
|
## Import
|
|
|
|
|
|
|
|
Forwarding rules can be imported using the `name`, e.g.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import google_compute_forwarding_rule.default website-forwarding-rule
|
|
|
|
```
|