google_compute_router

Represents a Router resource.

To get more information about Router, see:

Open in Cloud Shell

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
}
Open in Cloud Shell

Example Usage - Compute Router Encrypted Interconnect

resource "google_compute_router" "encrypted-interconnect-router" {
  name                          = "test-router"
  network                       = google_compute_network.network.name
  encrypted_interconnect_router = true
  bgp {
    asn = 64514
  }
}

resource "google_compute_network" "network" {
  name                    = "test-network"
  auto_create_subnetworks = false
}

Argument Reference

The following arguments are supported:


The bgp block supports:

The advertised_ip_ranges block supports:

Attributes Reference

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

Timeouts

This resource provides the following Timeouts configuration options:

Import

Router can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import Router using one of the formats above. For example:

import {
  id = "projects/{{project}}/regions/{{region}}/routers/{{name}}"
  to = google_compute_router.default
}

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

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