Skip to content

Commit

Permalink
feat: adds variables required for FS (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-awmalik authored Jul 12, 2023
1 parent ca72e53 commit 442b40d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 3 additions & 2 deletions modules/vpn_ha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,19 @@ module "vpn_ha" {
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| create\_vpn\_gateway | create a VPN gateway | `bool` | `true` | no |
| keepalive\_interval | The interval in seconds between BGP keepalive messages that are sent to the peer. | `number` | `20` | no |
| labels | Labels for vpn components | `map(string)` | `{}` | no |
| name | VPN gateway name, and prefix used for dependent resources. | `string` | n/a | yes |
| network | VPC used for the gateway and routes. | `string` | n/a | yes |
| peer\_external\_gateway | Configuration of an external VPN gateway to which this VPN is connected. | <pre>object({<br> redundancy_type = string<br> interfaces = list(object({<br> id = number<br> ip_address = string<br> }))<br> })</pre> | `null` | no |
| peer\_external\_gateway | Configuration of an external VPN gateway to which this VPN is connected. | <pre>object({<br> name = optional(string)<br> redundancy_type = string<br> interfaces = list(object({<br> id = number<br> ip_address = string<br> }))<br> })</pre> | `null` | no |
| peer\_gcp\_gateway | Self Link URL of the peer side HA GCP VPN gateway to which this VPN tunnel is connected. | `string` | `null` | no |
| project\_id | Project where resources will be created. | `string` | n/a | yes |
| region | Region used for resources. | `string` | n/a | yes |
| route\_priority | Route priority, defaults to 1000. | `number` | `1000` | no |
| 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 |
| 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_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 |
| 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 |

## Outputs
Expand Down
9 changes: 5 additions & 4 deletions modules/vpn_ha/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ resource "google_compute_ha_vpn_gateway" "ha_gateway" {
resource "google_compute_external_vpn_gateway" "external_gateway" {
provider = google-beta
count = var.peer_external_gateway != null ? 1 : 0
name = "external-${var.name}"
name = var.peer_external_gateway.name != null ? var.peer_external_gateway.name : "external-${var.name}"
project = var.project_id
redundancy_type = var.peer_external_gateway.redundancy_type
description = "Terraform managed external VPN gateway"
Expand Down Expand Up @@ -94,15 +94,16 @@ resource "google_compute_router" "router" {
description = range.value
}
}
asn = var.router_asn
asn = var.router_asn
keepalive_interval = var.keepalive_interval
}
}

resource "google_compute_router_peer" "bgp_peer" {
for_each = var.tunnels
region = var.region
project = var.project_id
name = "${var.name}-${each.key}"
name = each.value.bgp_session_name != null ? each.value.bgp_session_name : "${var.name}-${each.key}"
router = local.router
peer_ip_address = each.value.bgp_peer.address
peer_asn = each.value.bgp_peer.asn
Expand Down Expand Up @@ -146,7 +147,7 @@ resource "google_compute_router_interface" "router_interface" {
for_each = var.tunnels
project = var.project_id
region = var.region
name = "${var.name}-${each.key}"
name = each.value.bgp_session_name != null ? each.value.bgp_session_name : "${var.name}-${each.key}"
router = local.router
ip_range = each.value.bgp_session_range == "" ? null : each.value.bgp_session_range
vpn_tunnel = google_compute_vpn_tunnel.tunnels[each.key].name
Expand Down
8 changes: 8 additions & 0 deletions modules/vpn_ha/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
variable "peer_external_gateway" {
description = "Configuration of an external VPN gateway to which this VPN is connected."
type = object({
name = optional(string)
redundancy_type = string
interfaces = list(object({
id = number
Expand Down Expand Up @@ -74,6 +75,12 @@ variable "router_asn" {
default = 64514
}

variable "keepalive_interval" {
description = "The interval in seconds between BGP keepalive messages that are sent to the peer."
type = number
default = 20
}

variable "router_name" {
description = "Name of router, leave blank to create one."
type = string
Expand All @@ -87,6 +94,7 @@ variable "tunnels" {
address = string
asn = number
})
bgp_session_name = optional(string)
bgp_peer_options = object({
ip_address = string
advertise_groups = list(string)
Expand Down

0 comments on commit 442b40d

Please sign in to comment.