» google_compute_router

Represents a Router resource.

To get more information about Router, see:

» Example Usage - Router Basic

resource "google_compute_router" "foobar" {
  name    = "my-router"
  network = "${google_compute_network.foobar.name}"
  bgp {
    asn               = 64514
    advertise_mode    = "CUSTOM"
    advertised_groups = ["ALL_SUBNETS"]
    advertised_ip_ranges {
      range = "1.2.3.4"
    }
    advertised_ip_ranges {
      range = "6.7.0.0/16"
    }
  }
}

resource "google_compute_network" "foobar" {
  name = "my-network"
  auto_create_subnetworks = false
}

» 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 [a-z]([-a-z0-9]*[a-z0-9])? 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.

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

  • advertise_mode - (Optional) User-specified flag to indicate which mode to use for advertisement. Valid values of this enum field are: DEFAULT, CUSTOM

  • advertised_groups - (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

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

The advertised_ip_ranges block supports:

  • range - (Optional) 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:

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 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}}