GoogleComputeForwardingRule class final

Factory wrapper for google_compute_forwarding_rule.

A ForwardingRule resource. A ForwardingRule resource specifies which pool of target virtual machines to forward a packet to if it matches the given IPAddress, IPProtocol, portRange tuple.

The entry point ("frontend") of a GCP regional load balancer. A regional forwarding rule binds a VIP + port range (or port list) to either a regional target proxy (HTTP / HTTPS / TCP / SSL) for L7 / proxy-based balancing, or to a region_backend_service for L4 passthrough balancing.

The typical Regional Internal Application LB (L7 ILB) chain looks like:

google_compute_forwarding_rule              (this resource)
  → google_compute_region_target_https_proxy
    → google_compute_region_url_map
      → google_compute_region_backend_service

The L4 Internal Network LB chain instead routes traffic directly:

google_compute_forwarding_rule
  → google_compute_region_backend_service     (via backendService)

Required identity:

  • localName: Terraform local name (the address segment after google_compute_forwarding_rule.).
  • name: GCP forwarding rule resource name. 1-63 chars, RFC1035.

Strongly recommended:

  • region: GCP region the rule lives in. Schema marks the field Optional + Computed (provider falls back to the provider's default region), but production callers almost always pin it explicitly so the chain composes deterministically with sibling regional targets, subnetworks, and backend services.
  • target or backendService (exactly one):
    • target: self-link of an upstream regional target proxy. Required for proxy / Application Load Balancers. Typical L7 callers pass TfArg.ref(regionTargetHttpsProxy.selfLink).
    • backendService: self-link of a regional backend service. Required for Internal TCP/UDP Load Balancing and Network Load Balancing; must be omitted for all other LB types. Wave 6 focuses on the L7 path, so the dominant production pattern is target-only.
  • loadBalancingScheme: the dominant production setting for Regional Internal Application Load Balancers is ForwardingRuleLoadBalancingScheme.internalManaged. The legacy EXTERNAL value (default when unset) targets the older Regional external passthrough / proxy NLB family. INTERNAL is the L4 ILB passthrough scheme. EXTERNAL_MANAGED is the modern Regional external Application Load Balancer.
  • ipAddress: self-link or literal IP of a reserved GoogleComputeAddress (the regional sibling of GoogleComputeGlobalAddress). When omitted GCP allocates an ephemeral IP — surprising in CI, set explicitly for stable VIPs.
  • portRange: a single port (e.g. '443') or a range (e.g. '80-443'). Required for proxy / Application LBs.

For Internal forwarding rules (loadBalancingScheme: INTERNAL or INTERNAL_MANAGED):

  • network: self-link of the VPC the rule's VIP belongs to.
  • subnetwork: self-link of the subnet the VIP is allocated from. Both are required by the API for internal schemes; the schema marks them Optional + Computed only because external rules omit them.

Mutual exclusivity:

  • target vs backendService: exactly one. Setting both is rejected at apply time.
  • portRange, ports, allPorts: pairwise mutually exclusive. Pick one. Application LBs use portRange. L4 internal passthrough LBs typically use ports (a discrete list, up to 5) or allPorts.

networkTier accepts both PREMIUM and STANDARD for regional rules (unlike global rules, which only accept PREMIUM). When ipAddress is set, the network tier must match the address's tier. Leave null for the provider default (PREMIUM).

ipAddressRef is the output reference to ip_address — populated with the actual VIP after apply. Useful when ipAddress was left unset and GCP allocated an ephemeral IP, or when downstream DNS records need the resolved address. (ip_address is optional + computed; the derive gate skips it, so ipAddressRef is the sole reference accessor.)

pscConnectionId is populated only for Private Service Connect consumer forwarding rules; empty otherwise. pscConnectionStatus values: STATUS_UNSPECIFIED / PENDING / ACCEPTED / REJECTED / CLOSED. baseForwardingRule is set when this rule has source_ip_ranges and shares an [ip, protocol, port] tuple with a sibling rule without source ranges. serviceName is the internal fully qualified service name; populated only for INTERNAL load balancing rules that set serviceLabel.

Example (Regional Internal Application LB frontend):

final ilbFwd = GoogleComputeForwardingRule(
  localName: 'ilb',
  name: TfArg.literal('ilb-https-frontend'),
  region: TfArg.literal('us-central1'),
  target: TfArg.ref(regionTargetHttpsProxy.selfLink),
  network: TfArg.ref(vpc.selfLink),
  subnetwork: TfArg.ref(ilbSubnet.selfLink),
  ipAddress: TfArg.ref(ilbVip.selfLink),
  ipProtocol: TfArg.literal(ForwardingRuleIpProtocol.tcp),
  portRange: TfArg.literal('443'),
  loadBalancingScheme:
      TfArg.literal(ForwardingRuleLoadBalancingScheme.internalManaged),
);

Composition pattern: extends Resource for runtime behavior.

Constructors

GoogleComputeForwardingRule({required String localName, required TfArg<String> name, TfArg<String>? region, TfArg<String>? target, TfArg<String>? backendService, TfArg<String>? ipAddress, TfArg<ForwardingRuleIpProtocol>? ipProtocol, TfArg<ForwardingRuleIpVersion>? ipVersion, TfArg<String>? portRange, TfArg<List<String>>? ports, TfArg<bool>? allPorts, TfArg<ForwardingRuleLoadBalancingScheme>? loadBalancingScheme, TfArg<String>? network, TfArg<String>? subnetwork, TfArg<ForwardingRuleNetworkTier>? networkTier, TfArg<List<String>>? sourceIpRanges, TfArg<String>? serviceLabel, List<ComputeForwardingRuleForwardingRuleServiceDirectoryRegistration>? serviceDirectoryRegistrations, TfArg<bool>? allowGlobalAccess, TfArg<bool>? allowPscGlobalAccess, TfArg<bool>? isMirroringCollector, TfArg<bool>? noAutomateDnsZone, TfArg<bool>? recreateClosedPsc, TfArg<String>? ipCollection, TfArg<Map<String, String>>? labels, TfArg<String>? description, TfArg<String>? project, LifecycleOptions? lifecycle, List<DependencyTarget>? dependsOn, String? provider, TfTimeouts? timeouts})

Properties

argMap Map<String, TfArg?>
Argument-name → TfArg map. Keys are snake_case (Terraform JSON name). Synth emits these keys directly; the factory is responsible for the camelCase → snake_case translation at construction time.
finalinherited
baseForwardingRule → TfRef<String>
Reference to base_forwarding_rule attribute.
no setter
creationTimestamp → TfRef<String>
Reference to creation_timestamp attribute.
no setter
dependsOn List<DependencyTarget>?
Optional depends_on = [...]. Each entry is a DependencyTarget — either a wholesale resource (rendered as bare address) or an explicit TfRef (rendered via bareAddress).
finalinherited
effectiveLabels → TfRef<Map<String, String>>
Reference to effective_labels attribute.
no setter
forwardingRuleId → TfRef<num>
Reference to forwarding_rule_id attribute.
no setter
hashCode int
The hash code for this object.
no setterinherited
id → TfRef<String>
Reference to id attribute.
no setter
ipAddressRef → TfRef<String>
Reference to ip_address — populated with the actual VIP after apply. (ip_address is optional + computed; the derive gate skips it, so this is the sole reference accessor.)
no setter
kind → ResourceKind
Always ResourceKind.resource. Overridden by Data.
no setterinherited
labelFingerprint → TfRef<String>
Reference to label_fingerprint attribute.
no setter
lifecycle → LifecycleOptions?
Optional lifecycle { ... } block.
finalinherited
localName String
User-supplied local name within a Stack.
finalinherited
nameRef → TfRef<String>
Reference to name attribute.
no setter
provider String?
Optional Terraform provider meta-argument: a provider name ('google-beta' on a GA type) or a name.alias pair ('google.eu').
finalinherited
pscConnectionId → TfRef<String>
Reference to psc_connection_id attribute.
no setter
pscConnectionStatus → TfRef<String>
Reference to psc_connection_status attribute.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
Reference to self_link attribute.
no setter
sensitiveFields Set<String>
Field names that are @Sensitive per the IR-derived per-resource constant. Curated factories override with a baked-in static const Set<String> (file-private in v0.5+).
no setter
serviceName → TfRef<String>
Reference to service_name attribute.
no setter
supportsDeletionProtection bool
Capability flag: true when this resource's underlying Terraform schema has a deletion_protection boolean attribute that the synth-time devMode flow can flip to false. Defaults to false; the codegen emitter overrides this to true for wrappers whose schema includes the attribute.
no setterinherited
terraformLabels → TfRef<Map<String, String>>
Reference to terraform_labels attribute.
no setter
terraformType String
Terraform resource type, e.g. google_pubsub_topic.
finalinherited
tfAddress String
no setterinherited
timeouts → TfTimeouts?
Optional timeouts { ... } block: how long Terraform waits for each operation. Provider-neutral like lifecycle — synth copies the duration strings verbatim, and terraform validate decides whether this resource's schema declares the operations set here.
finalinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

tfType → const String