Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds stack_type and an option to set the router name #110

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/vpn_ha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ module "vpn_ha" {
| router\_advertise\_config | Router custom advertisement configuration, ip\_ranges is a map of address ranges and descriptions. | <pre>object({<br> groups = list(string)<br> ip_ranges = map(string)<br> mode = string<br> })</pre> | `null` | no |
| router\_asn | Router ASN used for auto-created router. | `number` | `64514` | no |
| router\_name | Name of router, leave blank to create one. | `string` | `""` | no |
| stack\_type | The IP stack type will apply to all the tunnels associated with this VPN gateway. | `string` | `"IPV4_ONLY"` | no |
| tunnels | VPN tunnel configurations, bgp\_peer\_options is usually null. | <pre>map(object({<br> bgp_peer = object({<br> address = string<br> asn = number<br> })<br> bgp_session_name = optional(string)<br> bgp_peer_options = object({<br> ip_address = string<br> advertise_groups = list(string)<br> advertise_ip_ranges = map(string)<br> advertise_mode = string<br> route_priority = number<br> })<br> bgp_session_range = string<br> ike_version = number<br> vpn_gateway_interface = number<br> peer_external_gateway_interface = number<br> shared_secret = string<br> }))</pre> | `{}` | no |
| vpn\_gateway\_self\_link | self\_link of existing VPN gateway to be used for the vpn tunnel | `string` | `null` | no |

Expand Down
24 changes: 16 additions & 8 deletions modules/vpn_ha/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ locals {
}

resource "google_compute_ha_vpn_gateway" "ha_gateway" {
count = var.create_vpn_gateway == true ? 1 : 0
provider = google-beta
name = var.name
project = var.project_id
region = var.region
network = var.network
count = var.create_vpn_gateway == true ? 1 : 0
provider = google-beta
name = var.name
project = var.project_id
region = var.region
network = var.network
stack_type = var.stack_type
}

resource "google_compute_external_vpn_gateway" "external_gateway" {
Expand All @@ -60,10 +61,17 @@ resource "google_compute_external_vpn_gateway" "external_gateway" {
}
}

data "google_compute_router" "router" {
name = var.router_name == null ? "" : var.router_name
network = var.network
project = var.project_id
region = var.region
}

resource "google_compute_router" "router" {
provider = google-beta
count = var.router_name == "" ? 1 : 0
name = "vpn-${var.name}"
count = data.google_compute_router.router.name == null ? 1 : 0
name = var.router_name != "" ? var.router_name : "vpn-${var.name}"
project = var.project_id
region = var.region
network = var.network
Expand Down
6 changes: 6 additions & 0 deletions modules/vpn_ha/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ variable "name" {
type = string
}

variable "stack_type" {
description = "The IP stack type will apply to all the tunnels associated with this VPN gateway."
type = string
default = "IPV4_ONLY"
}

variable "network" {
description = "VPC used for the gateway and routes."
type = string
Expand Down