2015-09-04 20:54:18 +00:00
|
|
|
---
|
|
|
|
layout: "google"
|
|
|
|
page_title: "Google: google_compute_vpn_gateway"
|
2015-10-23 14:10:41 +00:00
|
|
|
sidebar_current: "docs-google-compute-vpn-gateway"
|
2015-09-04 20:54:18 +00:00
|
|
|
description: |-
|
|
|
|
Manages a VPN Gateway in the GCE network
|
|
|
|
---
|
|
|
|
|
|
|
|
# google\_compute\_vpn\_gateway
|
|
|
|
|
2016-03-31 10:37:17 +00:00
|
|
|
Manages a VPN Gateway in the GCE network. For more info, read the
|
2015-09-04 20:54:18 +00:00
|
|
|
[documentation](https://cloud.google.com/compute/docs/vpn).
|
|
|
|
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2017-04-17 10:17:54 +00:00
|
|
|
```hcl
|
2015-09-04 20:54:18 +00:00
|
|
|
resource "google_compute_network" "network1" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "network1"
|
|
|
|
ipv4_range = "10.120.0.0/16"
|
2015-09-04 20:54:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_vpn_gateway" "target_gateway" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "vpn1"
|
|
|
|
network = "${google_compute_network.network1.self_link}"
|
|
|
|
region = "${var.region}"
|
2015-09-04 20:54:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_address" "vpn_static_ip" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "vpn-static-ip"
|
|
|
|
region = "${var.region}"
|
2015-09-04 20:54:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_forwarding_rule" "fr_esp" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "fr-esp"
|
|
|
|
region = "${var.region}"
|
|
|
|
ip_protocol = "ESP"
|
|
|
|
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
|
|
|
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
2015-09-04 20:54:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_forwarding_rule" "fr_udp500" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "fr-udp500"
|
|
|
|
region = "${var.region}"
|
|
|
|
ip_protocol = "UDP"
|
|
|
|
port_range = "500"
|
|
|
|
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
|
|
|
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
2015-09-04 20:54:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_forwarding_rule" "fr_udp4500" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "fr-udp4500"
|
|
|
|
region = "${var.region}"
|
|
|
|
ip_protocol = "UDP"
|
|
|
|
port_range = "4500"
|
|
|
|
ip_address = "${google_compute_address.vpn_static_ip.address}"
|
|
|
|
target = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
2015-09-04 20:54:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_vpn_tunnel" "tunnel1" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "tunnel1"
|
|
|
|
region = "${var.region}"
|
|
|
|
peer_ip = "15.0.0.120"
|
|
|
|
shared_secret = "a secret message"
|
|
|
|
|
|
|
|
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}"
|
|
|
|
|
|
|
|
depends_on = [
|
|
|
|
"google_compute_forwarding_rule.fr_esp",
|
|
|
|
"google_compute_forwarding_rule.fr_udp500",
|
|
|
|
"google_compute_forwarding_rule.fr_udp4500",
|
|
|
|
]
|
2015-09-04 20:54:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_route" "route1" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "route1"
|
|
|
|
network = "${google_compute_network.network1.name}"
|
|
|
|
dest_range = "15.0.0.0/24"
|
|
|
|
priority = 1000
|
2015-09-04 20:54:18 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}"
|
|
|
|
}
|
2015-09-04 20:54:18 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `name` - (Required) A unique name for the resource, required by GCE. Changing
|
|
|
|
this forces a new resource to be created.
|
|
|
|
|
2017-02-18 22:48:50 +00:00
|
|
|
* `network` - (Required) The name or resource link to the network this VPN gateway
|
2016-09-03 09:51:20 +00:00
|
|
|
is accepting traffic for. Changing this forces a new resource to be created.
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
- - -
|
2015-09-04 20:54:18 +00:00
|
|
|
|
|
|
|
* `description` - (Optional) A description of the resource.
|
|
|
|
Changing this forces a new resource to be created.
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `project` - (Optional) The project in which the resource belongs. If it
|
|
|
|
is not provided, the provider project is used.
|
2015-09-04 20:54:18 +00:00
|
|
|
|
|
|
|
* `region` - (Optional) The region this gateway should sit in. If not specified,
|
2016-03-31 10:37:17 +00:00
|
|
|
the project region will be used. Changing this forces a new resource to be
|
2015-09-04 20:54:18 +00:00
|
|
|
created.
|
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
In addition to the arguments listed above, the following computed attributes are
|
|
|
|
exported:
|
2015-09-04 20:54:18 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `self_link` - The URI of the created resource.
|