Google Compute Engine VPN Gateway

This page shows how to write Terraform for Compute Engine VPN Gateway and write them securely.

google_compute_vpn_gateway (Terraform)

The VPN Gateway in Compute Engine can be configured in Terraform with the resource name google_compute_vpn_gateway. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

resource "google_compute_vpn_gateway" "gateway-2-to-1" {
  name    = "gateway-2-to-1"
  network =

resource "google_compute_address" "vpn-address-2-to-1" {
resource "google_compute_vpn_gateway" "this" {
  description = var.description
  name        =
  network     =
  project     = var.project
  region      = var.region


  • creation_timestamp requiredcomputed - string
    • Creation timestamp in RFC3339 text format.

  • description optional - string
    • An optional description of this resource.

  • gateway_id requiredcomputed - number
    • The unique identifier for the resource.

  • id optionalcomputed - string
  • name required - string
    • Name of the resource. Provided by the client when the resource is created. 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?' 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 - string
    • The network this VPN gateway is accepting traffic for.

  • project optionalcomputed - string
  • region optionalcomputed - string
    • The region this gateway should sit in.

  • self_link requiredcomputed - string

Explanation in Terraform Registry

Represents a VPN gateway running in GCP. This virtual device is managed by Google, but used only by you. To get more information about VpnGateway, see:

Frequently asked questions

What is Google Compute Engine VPN Gateway?

Google Compute Engine VPN Gateway is a resource for Compute Engine of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Compute Engine VPN Gateway?

For Terraform, the davidheryanto/etc and niveklabs/google source code examples are useful. See the Terraform Example section for further details.


Scan your IaC problem in 3 minutes for free

You can keep your IaC security for free. No credit card required.