pulumi_wasm_providers_gcp_mini::compute

Module route

source
Expand description

Represents a Route resource.

A route is a rule that specifies how certain packets should be handled by the virtual network. Routes are associated with virtual machines by tag, and the set of routes for a particular virtual machine is called its routing table. For each packet leaving a virtual machine, the system searches that virtual machine’s routing table for a single best matching route.

Routes match packets by destination IP address, preferring smaller or more specific ranges over larger ones. If there is a tie, the system selects the route with the smallest priority value. If there is still a tie, it uses the layer three and four packet headers to select just one of the remaining matching routes. The packet is then forwarded as specified by the next_hop field of the winning route – either to another virtual machine destination, a virtual machine gateway or a Compute Engine-operated gateway. Packets that do not match any route in the sending virtual machine’s routing table will be dropped.

A Route resource must have exactly one specification of either nextHopGateway, nextHopInstance, nextHopIp, nextHopVpnTunnel, or nextHopIlb.

To get more information about Route, see:

§Example Usage

§Route Basic

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = route::create(
        "default",
        RouteArgs::builder()
            .dest_range("15.0.0.0/24")
            .name("network-route")
            .network("${defaultNetwork.name}")
            .next_hop_ip("10.132.1.5")
            .priority(100)
            .build_struct(),
    );
    let defaultNetwork = network::create(
        "defaultNetwork",
        NetworkArgs::builder().name("compute-network").build_struct(),
    );
}

§Route Ilb

resources:
  default:
    type: gcp:compute:Network
    properties:
      name: compute-network
      autoCreateSubnetworks: false
  defaultSubnetwork:
    type: gcp:compute:Subnetwork
    name: default
    properties:
      name: compute-subnet
      ipCidrRange: 10.0.1.0/24
      region: us-central1
      network: ${default.id}
  hc:
    type: gcp:compute:HealthCheck
    properties:
      name: proxy-health-check
      checkIntervalSec: 1
      timeoutSec: 1
      tcpHealthCheck:
        port: '80'
  backend:
    type: gcp:compute:RegionBackendService
    properties:
      name: compute-backend
      region: us-central1
      healthChecks: ${hc.id}
  defaultForwardingRule:
    type: gcp:compute:ForwardingRule
    name: default
    properties:
      name: compute-forwarding-rule
      region: us-central1
      loadBalancingScheme: INTERNAL
      backendService: ${backend.id}
      allPorts: true
      network: ${default.name}
      subnetwork: ${defaultSubnetwork.name}
  route-ilb:
    type: gcp:compute:Route
    properties:
      name: route-ilb
      destRange: 0.0.0.0/0
      network: ${default.name}
      nextHopIlb: ${defaultForwardingRule.id}
      priority: 2000

§Route Ilb Vip

resources:
  producer:
    type: gcp:compute:Network
    properties:
      name: producer-vpc
      autoCreateSubnetworks: false
  producerSubnetwork:
    type: gcp:compute:Subnetwork
    name: producer
    properties:
      name: producer-subnet
      ipCidrRange: 10.0.1.0/24
      region: us-central1
      network: ${producer.id}
  consumer:
    type: gcp:compute:Network
    properties:
      name: consumer-vpc
      autoCreateSubnetworks: false
  consumerSubnetwork:
    type: gcp:compute:Subnetwork
    name: consumer
    properties:
      name: consumer-subnet
      ipCidrRange: 10.0.2.0/24
      region: us-central1
      network: ${consumer.id}
  peering1:
    type: gcp:compute:NetworkPeering
    properties:
      name: peering-producer-to-consumer
      network: ${consumer.id}
      peerNetwork: ${producer.id}
  peering2:
    type: gcp:compute:NetworkPeering
    properties:
      name: peering-consumer-to-producer
      network: ${producer.id}
      peerNetwork: ${consumer.id}
  hc:
    type: gcp:compute:HealthCheck
    properties:
      name: proxy-health-check
      checkIntervalSec: 1
      timeoutSec: 1
      tcpHealthCheck:
        port: '80'
  backend:
    type: gcp:compute:RegionBackendService
    properties:
      name: compute-backend
      region: us-central1
      healthChecks: ${hc.id}
  default:
    type: gcp:compute:ForwardingRule
    properties:
      name: compute-forwarding-rule
      region: us-central1
      loadBalancingScheme: INTERNAL
      backendService: ${backend.id}
      allPorts: true
      network: ${producer.name}
      subnetwork: ${producerSubnetwork.name}
  route-ilb:
    type: gcp:compute:Route
    properties:
      name: route-ilb
      destRange: 0.0.0.0/0
      network: ${consumer.name}
      nextHopIlb: ${default.ipAddress}
      priority: 2000
      tags:
        - tag1
        - tag2
    options:
      dependsOn:
        - ${peering1}
        - ${peering2}

§Import

Route can be imported using any of these accepted formats:

  • projects/{{project}}/global/routes/{{name}}

  • {{project}}/{{name}}

  • {{name}}

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

$ pulumi import gcp:compute/route:Route default projects/{{project}}/global/routes/{{name}}
$ pulumi import gcp:compute/route:Route default {{project}}/{{name}}
$ pulumi import gcp:compute/route:Route default {{name}}

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments