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 1d00f42
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 67 deletions.
30 changes: 5 additions & 25 deletions modules/lb_http_ext_global/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ participating groups are equally capable as well.
```terraform
module "glb" {
source = "../modules/lb_http_ext_global"
name = "my-glb"
source = "../modules/lb_http_ext_global"
name = "my-glb"
backend_groups = module.vmseries.instance_group_self_links
max_rate_per_instance = 50000
}
Expand All @@ -31,36 +31,20 @@ Invalid value for field 'resource.backends[0].balancingMode': 'UTILIZATION'. Bal

Thus if you re-use the same IG for this module (HTTP LB) you need balancing_mode=RATE (and specify the max rate - don't worry it's not a circuit breaker). The balancing_mode=UTILIZATION is incompatible with ILB.

## IPv6 Support

The module supports dual-stack (IPv4+IPv6) GLB frontend. IPv6 is terminated on the Load Balancer and IPv4 is used for communication to the backend groups.

```terraform
module "glb" {
source = "../modules/lb_http_ext_global"
name = "my-glb"
backend_groups = module.vmseries.instance_group_self_links
max_rate_per_instance = 50000
ip_version = "IPV4_IPV6"
}
```

## Reference
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
### Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3, < 2.0 |
| <a name="requirement_google"></a> [google](#requirement\_google) | ~> 4.54 |
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 4.54 |

### Providers

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | ~> 4.54 |
| <a name="provider_google"></a> [google](#provider\_google) | >= 4.54 |

### Modules

Expand All @@ -72,11 +56,8 @@ No modules.
|------|------|
| [google_compute_backend_service.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_backend_service) | resource |
| [google_compute_global_address.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_address) | resource |
| [google_compute_global_address.default6](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_address) | resource |
| [google_compute_global_forwarding_rule.http](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_forwarding_rule) | resource |
| [google_compute_global_forwarding_rule.http6](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_forwarding_rule) | resource |
| [google_compute_global_forwarding_rule.https](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_forwarding_rule) | resource |
| [google_compute_global_forwarding_rule.https6](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_forwarding_rule) | resource |
| [google_compute_health_check.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_health_check) | resource |
| [google_compute_ssl_certificate.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_ssl_certificate) | resource |
| [google_compute_target_http_proxy.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_target_http_proxy) | resource |
Expand All @@ -98,7 +79,7 @@ No modules.
| <a name="input_health_check_name"></a> [health\_check\_name](#input\_health\_check\_name) | Name for the health check. If not provided, defaults to `<var.name>-healthcheck`. | `string` | `null` | no |
| <a name="input_health_check_port"></a> [health\_check\_port](#input\_health\_check\_port) | TCP port to use for health check. | `number` | `80` | no |
| <a name="input_http_forward"></a> [http\_forward](#input\_http\_forward) | Set to `false` to disable HTTP port 80 forward | `bool` | `true` | no |
| <a name="input_ip_version"></a> [ip\_version](#input\_ip\_version) | IP version supported by the Load Balancer. Possible values: IPV4 (default) or IPV4\_IPV6. <br>Empty defaults to IPV4. | `string` | `"IPV4"` | no |
| <a name="input_ip_version"></a> [ip\_version](#input\_ip\_version) | IP version for the Global address (IPv4 or v6) - Empty defaults to IPV4 | `string` | `""` | no |
| <a name="input_max_connections_per_instance"></a> [max\_connections\_per\_instance](#input\_max\_connections\_per\_instance) | n/a | `number` | `null` | no |
| <a name="input_max_rate_per_instance"></a> [max\_rate\_per\_instance](#input\_max\_rate\_per\_instance) | n/a | `number` | `null` | no |
| <a name="input_max_utilization"></a> [max\_utilization](#input\_max\_utilization) | n/a | `number` | `null` | no |
Expand All @@ -116,6 +97,5 @@ No modules.
| Name | Description |
|------|-------------|
| <a name="output_address"></a> [address](#output\_address) | n/a |
| <a name="output_address6"></a> [address6](#output\_address6) | n/a |
| <a name="output_all"></a> [all](#output\_all) | Intended mainly for `depends_on` but currently succeeds prematurely (while forwarding rules and healtchecks are not yet usable). |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
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
2 changes: 1 addition & 1 deletion modules/lb_http_ext_global/versions.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
terraform {
required_version = ">= 1.3, < 2.0"
required_providers {
google = { version = "~> 4.54" }
google = { version = ">= 4.54" }
}
}

0 comments on commit 1d00f42

Please sign in to comment.