Google Compute Engine Global Forwarding Rule

This page shows how to write Terraform for Compute Engine Global Forwarding Rule and write them securely.

code-icon

Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.

get-started-button

Terraform Example (google_compute_global_forwarding_rule)

Represents a GlobalForwardingRule resource. Global forwarding rules are used to forward traffic to the correct load balancer for HTTP load balancing. Global forwarding rules can only be used for HTTP load balancing. For more information, see https://cloud.google.com/compute/docs/load-balancing/http/

Parameters

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

  • id optionalcomputed - string
  • ip_address optionalcomputed - string
    • The IP address that this forwarding rule serves. When a client sends traffic to this IP address, the forwarding rule directs the traffic to the target that you specify in the forwarding rule. The loadBalancingScheme and the forwarding rule's target determine the type of IP address that you can use. For detailed information, refer to IP address specifications. An address can be specified either by a literal IP address or a reference to an existing Address resource. If you don't specify a reserved IP address, an ephemeral IP address is assigned. The value must be set to 0.0.0.0 when the target is a targetGrpcProxy that has validateForProxyless field set to true. For Private Service Connect forwarding rules that forward traffic to Google APIs, IP address must be provided.

  • ip_protocol optionalcomputed - string
    • The IP protocol to which this rule applies. When the load balancing scheme is INTERNAL_SELF_MANAGED, only TCP is valid. This field must not be set if the global address is configured as a purpose of PRIVATE_SERVICE_CONNECT and addressType of INTERNAL Possible values: ["TCP", "UDP", "ESP", "AH", "SCTP", "ICMP"]

  • ip_version optional - string
    • The IP Version that will be used by this global forwarding rule. Possible values: ["IPV4", "IPV6"]

  • load_balancing_scheme optional - string
    • This signifies what the GlobalForwardingRule will be used for. The value of INTERNAL_SELF_MANAGED means that this will be used for Internal Global HTTP(S) LB. The value of EXTERNAL means that this will be used for External Global Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) (Beta only) Note: This field must be set "" if the global address is configured as a purpose of PRIVATE_SERVICE_CONNECT and addressType of INTERNAL. Default value: "EXTERNAL" Possible values: ["EXTERNAL", "INTERNAL_SELF_MANAGED"]

  • 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.

  • port_range optional - string
    • This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to ports in the specified range will be forwarded to target. Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port ranges. Some types of forwarding target have constraints on the acceptable ports: TargetHttpProxy: 80, 8080 TargetHttpsProxy: 443 TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 TargetSslProxy: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500

  • project optionalcomputed - string
  • self_link requiredcomputed - string
  • target required - string
    • The URL of the target resource to receive the matched traffic. The forwarded traffic must be of a type appropriate to the target object. For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets are valid. (Beta only) For global address with a purpose of PRIVATE_SERVICE_CONNECT and addressType of INTERNAL, only "all-apis" and "vpc-sc" are valid.

Example Usage (from GitHub)

github-iconBlockBucket/Esplora_Docker
resource "google_compute_global_forwarding_rule" "mainnet-electrs-tls" {
  name        = "explorer-forwarding-rule-mainnet-electrs-tls"
  target      = google_compute_target_ssl_proxy.mainnet-electrs-tls-proxy[0].self_link
  port_range  = "700"
  ip_protocol = "TCP"
  ip_address  = google_compute_global_address.client-lb[0].address
github-iconPoWx-Org/obtc-esplora
resource "google_compute_global_forwarding_rule" "mainnet-electrs-tls" {
  name        = "explorer-forwarding-rule-mainnet-electrs-tls"
  target      = google_compute_target_ssl_proxy.mainnet-electrs-tls-proxy[0].self_link
  port_range  = "700"
  ip_protocol = "TCP"
  ip_address  = google_compute_global_address.client-lb[0].address
github-iconBlockstream/esplora
resource "google_compute_global_forwarding_rule" "mainnet-electrs-tls" {
  name        = "explorer-forwarding-rule-mainnet-electrs-tls"
  target      = google_compute_target_ssl_proxy.mainnet-electrs-tls-proxy[0].self_link
  port_range  = "700"
  ip_protocol = "TCP"
  ip_address  = google_compute_global_address.client-lb[0].address

Frequently asked questions

What is Google Compute Engine Global Forwarding Rule?

Google Compute Engine Global Forwarding Rule 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 Global Forwarding Rule?

For Terraform, the BlockBucket/Esplora_Docker, PoWx-Org/obtc-esplora and Blockstream/esplora source code examples are useful. See the Terraform Example section for further details.