google_compute_ha_vpn_gateway

Represents a VPN gateway running in GCP. This virtual device is managed by Google, but used only by you. This type of VPN Gateway allows for the creation of VPN solutions with higher availability than classic Target VPN Gateways.

To get more information about HaVpnGateway, see:

Open in Cloud Shell

Example Usage - Ha Vpn Gateway Basic

resource "google_compute_ha_vpn_gateway" "ha_gateway1" {
  region   = "us-central1"
  name     = "ha-vpn-1"
  network  = google_compute_network.network1.id
}

resource "google_compute_network" "network1" {
  name                    = "network1"
  auto_create_subnetworks = false
}
Open in Cloud Shell

Example Usage - Ha Vpn Gateway Ipv6

resource "google_compute_ha_vpn_gateway" "ha_gateway1" {
  region   = "us-central1"
  name     = "ha-vpn-1"
  network  = google_compute_network.network1.id
  stack_type = "IPV4_IPV6"
}

resource "google_compute_network" "network1" {
  name                    = "network1"
  auto_create_subnetworks = false
}

Example Usage - Compute Ha Vpn Gateway Encrypted Interconnect

resource "google_compute_ha_vpn_gateway" "vpn-gateway" {
  name           = "test-ha-vpngw"
  network        = google_compute_network.network.id
  vpn_interfaces {
      id                      = 0
      interconnect_attachment = google_compute_interconnect_attachment.attachment1.self_link
  }
  vpn_interfaces {
      id                      = 1
      interconnect_attachment = google_compute_interconnect_attachment.attachment2.self_link
  }
}

resource "google_compute_interconnect_attachment" "attachment1" {
  name                     = "test-interconnect-attachment1"
  edge_availability_domain = "AVAILABILITY_DOMAIN_1"
  type                     = "PARTNER"
  router                   = google_compute_router.router.id
  encryption               = "IPSEC"
  ipsec_internal_addresses = [
    google_compute_address.address1.self_link,
  ]
}

resource "google_compute_interconnect_attachment" "attachment2" {
  name                     = "test-interconnect-attachment2"
  edge_availability_domain = "AVAILABILITY_DOMAIN_2"
  type                     = "PARTNER"
  router                   = google_compute_router.router.id
  encryption               = "IPSEC"
  ipsec_internal_addresses = [
    google_compute_address.address2.self_link,
  ]
}

resource "google_compute_address" "address1" {
  name          = "test-address1"
  address_type  = "INTERNAL"
  purpose       = "IPSEC_INTERCONNECT"
  address       = "192.168.1.0"
  prefix_length = 29
  network       = google_compute_network.network.self_link
}

resource "google_compute_address" "address2" {
  name          = "test-address2"
  address_type  = "INTERNAL"
  purpose       = "IPSEC_INTERCONNECT"
  address       = "192.168.2.0"
  prefix_length = 29
  network       = google_compute_network.network.self_link
}

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

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

Argument Reference

The following arguments are supported:


The vpn_interfaces 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

HaVpnGateway can be imported using any of these accepted formats:

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

import {
  id = "projects/{{project}}/regions/{{region}}/vpnGateways/{{name}}"
  to = google_compute_ha_vpn_gateway.default
}

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

$ terraform import google_compute_ha_vpn_gateway.default projects/{{project}}/regions/{{region}}/vpnGateways/{{name}}
$ terraform import google_compute_ha_vpn_gateway.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_ha_vpn_gateway.default {{region}}/{{name}}
$ terraform import google_compute_ha_vpn_gateway.default {{name}}

User Project Overrides

This resource supports User Project Overrides.