Skip to content

googleComputeRouter

Represents a Router resource.

To get more information about Router, see:

Example Usage - Router 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.*/
const googleComputeNetworkFoobar = new google.computeNetwork.ComputeNetwork(
  this,
  "foobar",
  {
    auto_create_subnetworks: false,
    name: "my-network",
  }
);
const googleComputeRouterFoobar = new google.computeRouter.ComputeRouter(
  this,
  "foobar_1",
  {
    bgp: [
      {
        advertise_mode: "CUSTOM",
        advertised_groups: ["ALL_SUBNETS"],
        advertised_ip_ranges: [
          {
            range: "1.2.3.4",
          },
          {
            range: "6.7.0.0/16",
          },
        ],
        asn: 64514,
      },
    ],
    name: "my-router",
    network: googleComputeNetworkFoobar.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeRouterFoobar.overrideLogicalId("foobar");

Example Usage - Compute Router Encrypted Interconnect

/*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: "test-network",
  }
);
new google.computeRouter.ComputeRouter(this, "encrypted-interconnect-router", {
  bgp: [
    {
      asn: 64514,
    },
  ],
  encrypted_interconnect_router: true,
  name: "test-router",
  network: googleComputeNetworkNetwork.name,
});

Argument Reference

The following arguments are supported:

  • name - (Required) Name of the resource. 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.

  • network - (Required) A reference to the network to which this router belongs.


  • description - (Optional) An optional description of this resource.

  • bgp - (Optional) BGP information specific to this router. Structure is documented below.

  • encryptedInterconnectRouter - (Optional) Indicates if a router is dedicated for use with encrypted VLAN attachments (interconnectAttachments).

  • region - (Optional) Region where the router resides.

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

The bgp block supports:

  • asn - (Required) Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, either 16-bit or 32-bit. The value will be fixed for this router resource. All VPN tunnels that link to this router will have the same local ASN.

  • advertiseMode - (Optional) User-specified flag to indicate which mode to use for advertisement. Default value is default. Possible values are default and custom.

  • advertisedGroups - (Optional) User-specified list of prefix groups 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 groups will be advertised in addition to any specified prefixes. Leave this field blank to advertise no custom groups. This enum field has the one valid value: ALL_SUBNETS

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

  • keepaliveInterval - (Optional) The interval in seconds between BGP keepalive messages that are sent to the peer. Hold time is three times the interval at which keepalive messages are sent, and the hold time is the maximum number of seconds allowed to elapse between successive keepalive messages that BGP receives from a peer. BGP will use the smaller of either the local hold time value or the peer's hold time value as the hold time for the BGP connection between the two peers. If set, this value must be between 20 and 60. The default is 20.

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.

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/{{name}}

  • creationTimestamp - Creation timestamp in RFC3339 text format.

  • selfLink - The URI of the created resource.

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

Router can be imported using any of these accepted formats:

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

User Project Overrides

This resource supports User Project Overrides.