Skip to content

Commit e24a5a5

Browse files
feat: Allow specifying HTTP and HTTPS port. (#409)
1 parent 01c68d8 commit e24a5a5

File tree

11 files changed

+94
-8
lines changed

11 files changed

+94
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ module "gce-lb-http" {
106106
| firewall\_networks | Names of the networks to create firewall rules in | `list(string)` | <pre>[<br> "default"<br>]</pre> | no |
107107
| firewall\_projects | Names of the projects to create firewall rules in | `list(string)` | <pre>[<br> "default"<br>]</pre> | no |
108108
| http\_forward | Set to `false` to disable HTTP port 80 forward | `bool` | `true` | no |
109+
| http\_port | The port for the HTTP load balancer | `number` | `80` | no |
110+
| https\_port | The port for the HTTPS load balancer | `number` | `443` | no |
109111
| https\_redirect | Set to `true` to enable https redirect on the lb. | `bool` | `false` | no |
110112
| ipv6\_address | An existing IPv6 address to use (the actual IP address value) | `string` | `null` | no |
111113
| labels | The labels to attach to resources created by this module | `map(string)` | `{}` | no |

autogen/main.tf.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ resource "google_compute_global_forwarding_rule" "http" {
3838
name = var.name
3939
target = google_compute_target_http_proxy.default[0].self_link
4040
ip_address = local.address
41-
port_range = "80"
41+
port_range = var.http_port
4242
labels = var.labels
4343
load_balancing_scheme = var.load_balancing_scheme
4444
network = local.internal_network
@@ -51,7 +51,7 @@ resource "google_compute_global_forwarding_rule" "https" {
5151
name = "${var.name}-https"
5252
target = google_compute_target_https_proxy.default[0].self_link
5353
ip_address = local.address
54-
port_range = "443"
54+
port_range = var.https_port
5555
labels = var.labels
5656
load_balancing_scheme = var.load_balancing_scheme
5757
network = local.internal_network

autogen/variables.tf.tmpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,23 @@ variable "server_tls_policy" {
317317
type = string
318318
default = null
319319
}
320+
321+
variable "http_port" {
322+
description = "The port for the HTTP load balancer"
323+
type = number
324+
default = 80
325+
validation {
326+
condition = var.http_port >= 1 && var.http_port <= 65535
327+
error_message = "You must specify exactly one port between 1 and 65535"
328+
}
329+
}
330+
331+
variable "https_port" {
332+
description = "The port for the HTTPS load balancer"
333+
type = number
334+
default = 443
335+
validation {
336+
condition = var.https_port >= 1 && var.https_port <= 65535
337+
error_message = "You must specify exactly one port between 1 and 65535"
338+
}
339+
}

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "google_compute_global_forwarding_rule" "http" {
3636
name = var.name
3737
target = google_compute_target_http_proxy.default[0].self_link
3838
ip_address = local.address
39-
port_range = "80"
39+
port_range = var.http_port
4040
labels = var.labels
4141
load_balancing_scheme = var.load_balancing_scheme
4242
network = local.internal_network
@@ -49,7 +49,7 @@ resource "google_compute_global_forwarding_rule" "https" {
4949
name = "${var.name}-https"
5050
target = google_compute_target_https_proxy.default[0].self_link
5151
ip_address = local.address
52-
port_range = "443"
52+
port_range = var.https_port
5353
labels = var.labels
5454
load_balancing_scheme = var.load_balancing_scheme
5555
network = local.internal_network

modules/dynamic_backends/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ module "gce-lb-http" {
9999
| firewall\_networks | Names of the networks to create firewall rules in | `list(string)` | <pre>[<br> "default"<br>]</pre> | no |
100100
| firewall\_projects | Names of the projects to create firewall rules in | `list(string)` | <pre>[<br> "default"<br>]</pre> | no |
101101
| http\_forward | Set to `false` to disable HTTP port 80 forward | `bool` | `true` | no |
102+
| http\_port | The port for the HTTP load balancer | `number` | `80` | no |
103+
| https\_port | The port for the HTTPS load balancer | `number` | `443` | no |
102104
| https\_redirect | Set to `true` to enable https redirect on the lb. | `bool` | `false` | no |
103105
| ipv6\_address | An existing IPv6 address to use (the actual IP address value) | `string` | `null` | no |
104106
| labels | The labels to attach to resources created by this module | `map(string)` | `{}` | no |

modules/dynamic_backends/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "google_compute_global_forwarding_rule" "http" {
3636
name = var.name
3737
target = google_compute_target_http_proxy.default[0].self_link
3838
ip_address = local.address
39-
port_range = "80"
39+
port_range = var.http_port
4040
labels = var.labels
4141
load_balancing_scheme = var.load_balancing_scheme
4242
network = local.internal_network
@@ -49,7 +49,7 @@ resource "google_compute_global_forwarding_rule" "https" {
4949
name = "${var.name}-https"
5050
target = google_compute_target_https_proxy.default[0].self_link
5151
ip_address = local.address
52-
port_range = "443"
52+
port_range = var.https_port
5353
labels = var.labels
5454
load_balancing_scheme = var.load_balancing_scheme
5555
network = local.internal_network

modules/dynamic_backends/variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,23 @@ variable "server_tls_policy" {
304304
type = string
305305
default = null
306306
}
307+
308+
variable "http_port" {
309+
description = "The port for the HTTP load balancer"
310+
type = number
311+
default = 80
312+
validation {
313+
condition = var.http_port >= 1 && var.http_port <= 65535
314+
error_message = "You must specify exactly one port between 1 and 65535"
315+
}
316+
}
317+
318+
variable "https_port" {
319+
description = "The port for the HTTPS load balancer"
320+
type = number
321+
default = 443
322+
validation {
323+
condition = var.https_port >= 1 && var.https_port <= 65535
324+
error_message = "You must specify exactly one port between 1 and 65535"
325+
}
326+
}

modules/serverless_negs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ module "lb-http" {
8282
| edge\_security\_policy | The resource URL for the edge security policy to associate with the backend service | `string` | `null` | no |
8383
| enable\_ipv6 | Enable IPv6 address on the CDN load-balancer | `bool` | `false` | no |
8484
| http\_forward | Set to `false` to disable HTTP port 80 forward | `bool` | `true` | no |
85+
| http\_port | The port for the HTTP load balancer | `number` | `80` | no |
86+
| https\_port | The port for the HTTPS load balancer | `number` | `443` | no |
8587
| https\_redirect | Set to `true` to enable https redirect on the lb. | `bool` | `false` | no |
8688
| ipv6\_address | An existing IPv6 address to use (the actual IP address value) | `string` | `null` | no |
8789
| labels | The labels to attach to resources created by this module | `map(string)` | `{}` | no |

modules/serverless_negs/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ resource "google_compute_global_forwarding_rule" "http" {
3535
name = var.name
3636
target = google_compute_target_http_proxy.default[0].self_link
3737
ip_address = local.address
38-
port_range = "80"
38+
port_range = var.http_port
3939
labels = var.labels
4040
load_balancing_scheme = var.load_balancing_scheme
4141
network = local.internal_network
@@ -48,7 +48,7 @@ resource "google_compute_global_forwarding_rule" "https" {
4848
name = "${var.name}-https"
4949
target = google_compute_target_https_proxy.default[0].self_link
5050
ip_address = local.address
51-
port_range = "443"
51+
port_range = var.https_port
5252
labels = var.labels
5353
load_balancing_scheme = var.load_balancing_scheme
5454
network = local.internal_network

modules/serverless_negs/variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,23 @@ variable "server_tls_policy" {
253253
type = string
254254
default = null
255255
}
256+
257+
variable "http_port" {
258+
description = "The port for the HTTP load balancer"
259+
type = number
260+
default = 80
261+
validation {
262+
condition = var.http_port >= 1 && var.http_port <= 65535
263+
error_message = "You must specify exactly one port between 1 and 65535"
264+
}
265+
}
266+
267+
variable "https_port" {
268+
description = "The port for the HTTPS load balancer"
269+
type = number
270+
default = 443
271+
validation {
272+
condition = var.https_port >= 1 && var.https_port <= 65535
273+
error_message = "You must specify exactly one port between 1 and 65535"
274+
}
275+
}

0 commit comments

Comments
 (0)