Skip to content

googleComputeRouterPeer

BGP information that must be configured into the routing stack to establish BGP peering. This information must specify the peer ASN and either the interface name, IP address, or peer IP address. Please refer to RFC4273.

To get more information about RouterBgpPeer, see:

Example Usage - Router Peer Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.computeRouterPeer.ComputeRouterPeer(this, "peer", {
  advertised_route_priority: 100,
  interface: "interface-1",
  name: "my-router-peer",
  peer_asn: 65513,
  peer_ip_address: "169.254.1.2",
  region: "us-central1",
  router: "my-router",
});

Example Usage - Router Peer Disabled

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.computeRouterPeer.ComputeRouterPeer(this, "peer", {
  advertised_route_priority: 100,
  enable: false,
  interface: "interface-1",
  name: "my-router-peer",
  peer_asn: 65513,
  peer_ip_address: "169.254.1.2",
  region: "us-central1",
  router: "my-router",
});

Example Usage - Router Peer Bfd

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.computeRouterPeer.ComputeRouterPeer(this, "peer", {
  advertised_route_priority: 100,
  bfd: [
    {
      min_receive_interval: 1000,
      min_transmit_interval: 1000,
      multiplier: 5,
      session_initialization_mode: "ACTIVE",
    },
  ],
  interface: "interface-1",
  name: "my-router-peer",
  peer_asn: 65513,
  peer_ip_address: "169.254.1.2",
  region: "us-central1",
  router: "my-router",
});

Example Usage - Router Peer Router Appliance

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNetworkNetwork = new google.computeNetwork.ComputeNetwork(
  this,
  "network",
  {
    auto_create_subnetworks: false,
    name: "my-router-net",
  }
);
const googleComputeSubnetworkSubnetwork =
  new google.computeSubnetwork.ComputeSubnetwork(this, "subnetwork", {
    ip_cidr_range: "10.0.0.0/16",
    name: "my-router-sub",
    network: googleComputeNetworkNetwork.selfLink,
    region: "us-central1",
  });
const googleNetworkConnectivityHubHub =
  new google.networkConnectivityHub.NetworkConnectivityHub(this, "hub", {
    name: "my-router-hub",
  });
const googleComputeAddressAddrIntf = new google.computeAddress.ComputeAddress(
  this,
  "addr_intf",
  {
    address_type: "INTERNAL",
    name: "my-router-addr-intf",
    region: googleComputeSubnetworkSubnetwork.region,
    subnetwork: googleComputeSubnetworkSubnetwork.id,
  }
);
const googleComputeAddressAddrIntfRedundant =
  new google.computeAddress.ComputeAddress(this, "addr_intf_redundant", {
    address_type: "INTERNAL",
    name: "my-router-addr-intf-red",
    region: googleComputeSubnetworkSubnetwork.region,
    subnetwork: googleComputeSubnetworkSubnetwork.id,
  });
const googleComputeAddressAddrPeer = new google.computeAddress.ComputeAddress(
  this,
  "addr_peer",
  {
    address_type: "INTERNAL",
    name: "my-router-addr-peer",
    region: googleComputeSubnetworkSubnetwork.region,
    subnetwork: googleComputeSubnetworkSubnetwork.id,
  }
);
const googleComputeInstanceInstance =
  new google.computeInstance.ComputeInstance(this, "instance", {
    boot_disk: [
      {
        initialize_params: [
          {
            image: "debian-cloud/debian-11",
          },
        ],
      },
    ],
    can_ip_forward: true,
    machine_type: "e2-medium",
    name: "router-appliance",
    network_interface: [
      {
        network_ip: googleComputeAddressAddrPeer.address,
        subnetwork: googleComputeSubnetworkSubnetwork.selfLink,
      },
    ],
    zone: "us-central1-a",
  });
const googleComputeRouterRouter = new google.computeRouter.ComputeRouter(
  this,
  "router",
  {
    bgp: [
      {
        asn: 64514,
      },
    ],
    name: "my-router-router",
    network: googleComputeNetworkNetwork.selfLink,
    region: googleComputeSubnetworkSubnetwork.region,
  }
);
const googleComputeRouterInterfaceInterfaceRedundant =
  new google.computeRouterInterface.ComputeRouterInterface(
    this,
    "interface_redundant",
    {
      name: "my-router-intf-red",
      private_ip_address: googleComputeAddressAddrIntfRedundant.address,
      region: googleComputeRouterRouter.region,
      router: googleComputeRouterRouter.name,
      subnetwork: googleComputeSubnetworkSubnetwork.selfLink,
    }
  );
new google.networkConnectivitySpoke.NetworkConnectivitySpoke(this, "spoke", {
  hub: googleNetworkConnectivityHubHub.id,
  linked_router_appliance_instances: [
    {
      instances: [
        {
          ip_address: googleComputeAddressAddrPeer.address,
          virtual_machine: googleComputeInstanceInstance.selfLink,
        },
      ],
      site_to_site_data_transfer: false,
    },
  ],
  location: googleComputeSubnetworkSubnetwork.region,
  name: "my-router-spoke",
});
const googleComputeRouterInterfaceInterface =
  new google.computeRouterInterface.ComputeRouterInterface(this, "interface", {
    name: "my-router-intf",
    private_ip_address: googleComputeAddressAddrIntf.address,
    redundant_interface: googleComputeRouterInterfaceInterfaceRedundant.name,
    region: googleComputeRouterRouter.region,
    router: googleComputeRouterRouter.name,
    subnetwork: googleComputeSubnetworkSubnetwork.selfLink,
  });
new google.computeRouterPeer.ComputeRouterPeer(this, "peer", {
  interface: googleComputeRouterInterfaceInterface.name,
  name: "my-router-peer",
  peer_asn: 65513,
  peer_ip_address: googleComputeAddressAddrPeer.address,
  region: googleComputeRouterRouter.region,
  router: googleComputeRouterRouter.name,
  router_appliance_instance: googleComputeInstanceInstance.selfLink,
});

Argument Reference

The following arguments are supported:

  • name - (Required) Name of this BGP peer. 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 [aZ]([AZ09]*[aZ09])? 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.

  • interface - (Required) Name of the interface the BGP peer is associated with.

  • peerIpAddress - (Required) IP address of the BGP interface outside Google Cloud Platform. Only IPv4 is supported.

  • peerAsn - (Required) Peer BGP Autonomous System Number (ASN). Each BGP interface may use a different value.

  • router - (Required) The name of the Cloud Router in which this BgpPeer will be configured.


  • ipAddress - (Optional) IP address of the interface inside Google Cloud Platform. Only IPv4 is supported.

  • advertisedRoutePriority - (Optional) The priority of routes advertised to this BGP peer. Where there is more than one matching route of maximum length, the routes with the lowest priority value win.

  • advertiseMode - (Optional) User-specified flag to indicate which mode to use for advertisement. Valid values of this enum field are: default, custom Default value is default. Possible values are default and custom.

  • advertisedGroups - (Optional) User-specified list of prefix groups to advertise in custom mode, which can take one of the following options:

    • allSubnets: Advertises all available subnets, including peer VPC subnets.
    • allVpcSubnets: Advertises the router's own VPC subnets.
    • allPeerVpcSubnets: Advertises peer subnets of the router's VPC network.

    Note that this field can only be populated if advertiseMode is custom and overrides the list defined for the router (in the "bgp" message). These groups are advertised in addition to any specified prefixes. Leave this field blank to advertise no custom groups.

  • advertisedIpRanges - (Optional) User-specified list of individual IP ranges to advertise in custom mode. This field can only be populated if advertiseMode is custom and is advertised to all peers of the router. These IP ranges will be advertised in addition to any specified groups. Leave this field blank to advertise no custom IP ranges. Structure is documented below.

  • bfd - (Optional) BFD configuration for the BGP peering. Structure is documented below.

  • enable - (Optional) The status of the BGP peer connection. If set to false, any active session with the peer is terminated and all associated routing information is removed. If set to true, the peer connection can be established with routing information. The default is true.

  • routerApplianceInstance - (Optional) The URI of the VM instance that is used as third-party router appliances such as Next Gen Firewalls, Virtual Routers, or Router Appliances. The VM instance must be located in zones contained in the same region as this Cloud Router. The VM instance is the peer side of the BGP session.

  • region - (Optional) Region where the router and BgpPeer reside. If it is not provided, the provider region is used.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The advertisedIpRanges block supports:

  • range - (Required) The IP range to advertise. The value must be a CIDR-formatted string.

  • description - (Optional) User-specified description for the IP range.

The bfd block supports:

  • sessionInitializationMode - (Required) The BFD session initialization mode for this BGP peer. If set to active, the Cloud Router will initiate the BFD session for this BGP peer. If set to passive, the Cloud Router will wait for the peer router to initiate the BFD session for this BGP peer. If set to disabled, BFD is disabled for this BGP peer. Possible values are active, disabled, and passive.

  • minTransmitInterval - (Optional) The minimum interval, in milliseconds, between BFD control packets transmitted to the peer router. The actual value is negotiated between the two routers and is equal to the greater of this value and the corresponding receive interval of the other router. If set, this value must be between 1000 and 30000.

  • minReceiveInterval - (Optional) The minimum interval, in milliseconds, between BFD control packets received from the peer router. The actual value is negotiated between the two routers and is equal to the greater of this value and the transmit interval of the other router. If set, this value must be between 1000 and 30000.

  • multiplier - (Optional) The number of consecutive BFD packets that must be missed before BFD declares that a peer is unavailable. If set, the value must be a value between 5 and 16.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/regions/{{region}}/routers/{{router}}/{{name}}

  • managementType - The resource that configures and manages this BGP peer.

    • managedByUser is the default value and can be managed by you or other users
    • managedByAttachment is a BGP peer that is configured and managed by Cloud Interconnect, specifically by an InterconnectAttachment of type PARTNER. Google automatically creates, updates, and deletes this type of BGP peer when the PARTNER InterconnectAttachment is created, updated, or deleted.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

RouterBgpPeer can be imported using any of these accepted formats:

$ terraform import google_compute_router_peer.default projects/{{project}}/regions/{{region}}/routers/{{router}}/{{name}}
$ terraform import google_compute_router_peer.default {{project}}/{{region}}/{{router}}/{{name}}
$ terraform import google_compute_router_peer.default {{region}}/{{router}}/{{name}}
$ terraform import google_compute_router_peer.default {{router}}/{{name}}

User Project Overrides

This resource supports User Project Overrides.