Skip to content

Commit

Permalink
Separating the changes; reverting modules/lb_http_ext_global
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelrn committed Jul 30, 2024
1 parent 5f97b59 commit a6e7fe4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 41 deletions.
24 changes: 1 addition & 23 deletions modules/lb_http_ext_global/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ resource "google_compute_global_forwarding_rule" "http" {
port_range = "80"
}

resource "google_compute_global_forwarding_rule" "http6" {
count = var.http_forward && contains(["IPV4_IPV6"], var.ip_version) ? 1 : 0
name = "${var.name}-http6"
target = google_compute_target_http_proxy.default[0].self_link
ip_address = google_compute_global_address.default6[0].address
port_range = "80"
}

resource "google_compute_global_forwarding_rule" "https" {
count = var.ssl ? 1 : 0
name = "${var.name}-https"
Expand All @@ -22,23 +14,9 @@ resource "google_compute_global_forwarding_rule" "https" {
port_range = "443"
}

resource "google_compute_global_forwarding_rule" "https6" {
count = var.ssl && contains(["IPV4_IPV6"], var.ip_version) ? 1 : 0
name = "${var.name}-https6"
target = google_compute_target_https_proxy.default[0].self_link
ip_address = google_compute_global_address.default6[0].address
port_range = "443"
}

resource "google_compute_global_address" "default" {
name = "${var.name}-address"
ip_version = "IPV4"
}

resource "google_compute_global_address" "default6" {
count = contains(["IPV4_IPV6"], var.ip_version) ? 1 : 0
name = "${var.name}-address6"
ip_version = "IPV6"
ip_version = var.ip_version
}

# HTTP proxy when ssl is false
Expand Down
12 changes: 3 additions & 9 deletions modules/lb_http_ext_global/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@ output "address" {
value = google_compute_global_address.default.address
}

output "address6" {
value = try(google_compute_global_address.default6[0].address, null)
}

output "all" {
description = "Intended mainly for `depends_on` but currently succeeds prematurely (while forwarding rules and healtchecks are not yet usable)."
value = {
google_compute_global_forwarding_rule_http = google_compute_global_forwarding_rule.http
google_compute_global_forwarding_rule_https = google_compute_global_forwarding_rule.https
google_compute_global_forwarding_rule_http6 = try(google_compute_global_forwarding_rule.http6[0], null)
google_compute_global_forwarding_rule_https6 = try(google_compute_global_forwarding_rule.https6[0], null)
google_compute_health_check = google_compute_health_check.default
google_compute_global_forwarding_rule_http = google_compute_global_forwarding_rule.http
google_compute_global_forwarding_rule_https = google_compute_global_forwarding_rule.https
google_compute_health_check = google_compute_health_check.default
}
}
11 changes: 2 additions & 9 deletions modules/lb_http_ext_global/variables.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
variable "ip_version" {
description = <<-EOF
IP version supported by the Load Balancer. Possible values: IPV4 (default) or IPV4_IPV6.
Empty defaults to IPV4.
EOF
description = "IP version for the Global address (IPv4 or v6) - Empty defaults to IPV4"
type = string
default = "IPV4"
validation {
condition = contains(["", "IPV4", "IPV4_IPV6"], var.ip_version)
error_message = "ip_version value must be either '', 'IPV4' or 'IPV4_IPV6'."
}
default = ""
}

variable "name" {
Expand Down

0 comments on commit a6e7fe4

Please sign in to comment.