Skip to content

googleComputeVpnGateway

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:

\~> Warning: Classic VPN is deprecating certain functionality on October 31, 2021. For more information, see the Classic VPN partial deprecation page.

Example Usage - Target Vpn Gateway 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 googleComputeAddressVpnStaticIp =
  new google.computeAddress.ComputeAddress(this, "vpn_static_ip", {
    name: "vpn-static-ip",
  });
const googleComputeNetworkNetwork1 = new google.computeNetwork.ComputeNetwork(
  this,
  "network1",
  {
    name: "network-1",
  }
);
const googleComputeVpnGatewayTargetGateway =
  new google.computeVpnGateway.ComputeVpnGateway(this, "target_gateway", {
    name: "vpn-1",
    network: googleComputeNetworkNetwork1.id,
  });
const googleComputeForwardingRuleFrEsp =
  new google.computeForwardingRule.ComputeForwardingRule(this, "fr_esp", {
    ip_address: googleComputeAddressVpnStaticIp.address,
    ip_protocol: "ESP",
    name: "fr-esp",
    target: googleComputeVpnGatewayTargetGateway.id,
  });
const googleComputeForwardingRuleFrUdp4500 =
  new google.computeForwardingRule.ComputeForwardingRule(this, "fr_udp4500", {
    ip_address: googleComputeAddressVpnStaticIp.address,
    ip_protocol: "UDP",
    name: "fr-udp4500",
    port_range: "4500",
    target: googleComputeVpnGatewayTargetGateway.id,
  });
const googleComputeForwardingRuleFrUdp500 =
  new google.computeForwardingRule.ComputeForwardingRule(this, "fr_udp500", {
    ip_address: googleComputeAddressVpnStaticIp.address,
    ip_protocol: "UDP",
    name: "fr-udp500",
    port_range: "500",
    target: googleComputeVpnGatewayTargetGateway.id,
  });
const googleComputeVpnTunnelTunnel1 =
  new google.computeVpnTunnel.ComputeVpnTunnel(this, "tunnel1", {
    depends_on: [
      `\${${googleComputeForwardingRuleFrEsp.fqn}}`,
      `\${${googleComputeForwardingRuleFrUdp500.fqn}}`,
      `\${${googleComputeForwardingRuleFrUdp4500.fqn}}`,
    ],
    name: "tunnel1",
    peer_ip: "15.0.0.120",
    shared_secret: "a secret message",
    target_vpn_gateway: googleComputeVpnGatewayTargetGateway.id,
  });
new google.computeRoute.ComputeRoute(this, "route1", {
  dest_range: "15.0.0.0/24",
  name: "route1",
  network: googleComputeNetworkNetwork1.name,
  next_hop_vpn_tunnel: googleComputeVpnTunnelTunnel1.id,
  priority: 1000,
});

Argument Reference

The following arguments are supported:

  • name - (Required) 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 [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) The network this VPN gateway is accepting traffic for.


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

  • region - (Optional) The region this gateway should sit in.

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

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

  • creationTimestamp - Creation timestamp in RFC3339 text format.

  • gatewayId - The unique identifier for the resource.

  • selfLink - The URI of the created resource.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

VpnGateway can be imported using any of these accepted formats:

$ terraform import google_compute_vpn_gateway.default projects/{{project}}/regions/{{region}}/targetVpnGateways/{{name}}
$ terraform import google_compute_vpn_gateway.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_vpn_gateway.default {{region}}/{{name}}
$ terraform import google_compute_vpn_gateway.default {{name}}

User Project Overrides

This resource supports User Project Overrides.