Skip to content
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Current version is 12.0. Upgrade guides:
```HCL
module "gce-lb-http" {
source = "GoogleCloudPlatform/lb-http/google"
version = "~> 9.0"
version = "~> 12.0"

project = "my-project-id"
name = "group-http-lb"
Expand Down Expand Up @@ -116,6 +116,8 @@ module "gce-lb-http" {
| load\_balancing\_scheme | Load balancing scheme type (EXTERNAL for classic external load balancer, EXTERNAL\_MANAGED for Envoy-based load balancer, and INTERNAL\_SELF\_MANAGED for traffic director) | `string` | `"EXTERNAL"` | no |
| managed\_ssl\_certificate\_domains | Create Google-managed SSL certificates for specified domains. Requires `ssl` to be set to `true` | `list(string)` | `[]` | no |
| name | Name for the forwarding rule and prefix for supporting resources | `string` | n/a | yes |
| name\_prefixes | Map of resource name prefixes allowing name customization. `null` values fallback to module defaults. | <pre>object({<br> address = optional(string, null)<br> address_ipv6 = optional(string, null)<br> certificate = optional(string, null)<br> http_forwarding_rule = optional(string, null)<br> http_ipv6_forwarding_rule = optional(string, null)<br> https_forwarding_rule = optional(string, null)<br> https_ipv6_forwarding_rule = optional(string, null)<br> target_http_proxy = optional(string, null)<br> target_https_proxy = optional(string, null)<br> url_map = optional(string, null)<br> url_map_https_redirect = optional(string, null)<br> backend_service = optional(string, null)<br> health_check = optional(string, null)<br> })</pre> | `{}` | no |
| name\_suffixes | Map of suffixes to the created resource names. | <pre>object({<br> address = optional(string, "-address")<br> address_ipv6 = optional(string, "-ipv6-address")<br> certificate = optional(string, "-cert")<br> http_forwarding_rule = optional(string, "")<br> http_ipv6_forwarding_rule = optional(string, "-ipv6-http")<br> https_forwarding_rule = optional(string, "-https")<br> https_ipv6_forwarding_rule = optional(string, "-ipv6-https")<br> target_http_proxy = optional(string, "-http-proxy")<br> target_https_proxy = optional(string, "-https-proxy")<br> url_map = optional(string, "-url-map")<br> url_map_https_redirect = optional(string, "-https-redirect")<br> backend_service = optional(string, "")<br> health_check = optional(string, "")<br> })</pre> | `{}` | no |
| network | Network for INTERNAL\_SELF\_MANAGED load balancing scheme | `string` | `"default"` | no |
| private\_key | Content of the private SSL key. Requires `ssl` to be set to `true` and `create_ssl_certificate` set to `true` | `string` | `null` | no |
| project | The project to deploy to, if not set the default provider project is used. | `string` | n/a | yes |
Expand Down
16 changes: 8 additions & 8 deletions autogen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ intended for Terraform 0.12.x is [v4.5.0](https://registry.terraform.io/modules/

Current version is 12.0. Upgrade guides:

- [2.X -> 3.0](/docs/upgrading-v2.0.0-v3.0.0.md)
- [3.X -> 4.0](/docs/upgrading_to_v4.0.md)
- [6.X -> 7.0](/docs/upgrading_to_v7.0.md)
- [7.X -> 8.0](/docs/upgrading_to_v8.0.md)
- [8.X -> 9.0](/docs/upgrading_to_v9.0.md)
- [9.X -> 10.0](/docs/upgrading_to_v10.0.md)
- [10.X -> 11.0](/docs/upgrading_to_v11.0.md)
- [2.X -> 3.0](https://github.com/terraform-google-modules/terraform-google-lb-http/blob/master/docs/upgrading_to_v3.0.0.md)
- [3.X -> 4.0](https://github.com/terraform-google-modules/terraform-google-lb-http/blob/master/docs/upgrading_to_v4.0.md)
- [6.X -> 7.0](https://github.com/terraform-google-modules/terraform-google-lb-http/blob/master/docs/upgrading_to_v7.0.md)
- [7.X -> 8.0](https://github.com/terraform-google-modules/terraform-google-lb-http/blob/master/docs/upgrading_to_v8.0.md)
- [8.X -> 9.0](https://github.com/terraform-google-modules/terraform-google-lb-http/blob/master/docs/upgrading_to_v9.0.md)
- [9.X -> 10.0](https://github.com/terraform-google-modules/terraform-google-lb-http/blob/master/docs/upgrading_to_v10.0.md)
- [10.X -> 11.0](https://github.com/terraform-google-modules/terraform-google-lb-http/blob/master/docs/upgrading_to_v11.0.md)

## Usage

Expand All @@ -62,7 +62,7 @@ module "gce-lb-http" {
module "lb-http" {
{% endif %}
source = "GoogleCloudPlatform/lb-http/google{{ module_path }}"
version = "~> 9.0"
version = "~> 12.0"

project = "my-project-id"
{% if serverless %}
Expand Down
28 changes: 14 additions & 14 deletions autogen/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ resource "google_compute_global_forwarding_rule" "http" {
provider = google-beta
project = var.project
count = local.create_http_forward ? 1 : 0
name = var.name
name = "${var.name_prefixes.http_forwarding_rule != null ? var.name_prefixes.http_forwarding_rule : var.name}${var.name_suffixes.http_forwarding_rule}"
target = google_compute_target_http_proxy.default[0].self_link
ip_address = local.address
port_range = var.http_port
Expand All @@ -48,7 +48,7 @@ resource "google_compute_global_forwarding_rule" "https" {
provider = google-beta
project = var.project
count = var.ssl ? 1 : 0
name = "${var.name}-https"
name = "${var.name_prefixes.https_forwarding_rule != null ? var.name_prefixes.https_forwarding_rule : var.name}${var.name_suffixes.https_forwarding_rule}"
target = google_compute_target_https_proxy.default[0].self_link
ip_address = local.address
port_range = var.https_port
Expand All @@ -61,7 +61,7 @@ resource "google_compute_global_address" "default" {
provider = google-beta
count = local.is_internal ? 0 : var.create_address ? 1 : 0
project = var.project
name = "${var.name}-address"
name = "${var.name_prefixes.address != null ? var.name_prefixes.address : var.name}${var.name_suffixes.address}"
ip_version = "IPV4"
labels = var.labels
}
Expand All @@ -72,7 +72,7 @@ resource "google_compute_global_forwarding_rule" "http_ipv6" {
provider = google-beta
project = var.project
count = (var.enable_ipv6 && local.create_http_forward) ? 1 : 0
name = "${var.name}-ipv6-http"
name = "${var.name_prefixes.http_ipv6_forwarding_rule != null ? var.name_prefixes.http_ipv6_forwarding_rule : var.name}${var.name_suffixes.http_ipv6_forwarding_rule}"
target = google_compute_target_http_proxy.default[0].self_link
ip_address = local.ipv6_address
port_range = "80"
Expand All @@ -85,7 +85,7 @@ resource "google_compute_global_forwarding_rule" "https_ipv6" {
provider = google-beta
project = var.project
count = var.enable_ipv6 && var.ssl ? 1 : 0
name = "${var.name}-ipv6-https"
name = "${var.name_prefixes.https_ipv6_forwarding_rule != null ? var.name_prefixes.https_ipv6_forwarding_rule : var.name}${var.name_suffixes.https_ipv6_forwarding_rule}"
target = google_compute_target_https_proxy.default[0].self_link
ip_address = local.ipv6_address
port_range = "443"
Expand All @@ -98,7 +98,7 @@ resource "google_compute_global_address" "default_ipv6" {
provider = google-beta
count = local.is_internal ? 0 : (var.enable_ipv6 && var.create_ipv6_address) ? 1 : 0
project = var.project
name = "${var.name}-ipv6-address"
name = "${var.name_prefixes.address_ipv6 != null ? var.name_prefixes.address_ipv6 : var.name}${var.name_suffixes.address_ipv6}"
ip_version = "IPV6"
labels = var.labels
}
Expand All @@ -108,15 +108,15 @@ resource "google_compute_global_address" "default_ipv6" {
resource "google_compute_target_http_proxy" "default" {
project = var.project
count = local.create_http_forward ? 1 : 0
name = "${var.name}-http-proxy"
name = "${var.name_prefixes.target_http_proxy != null ? var.name_prefixes.target_http_proxy : var.name}${var.name_suffixes.target_http_proxy}"
url_map = var.https_redirect == false ? local.url_map : join("", google_compute_url_map.https_redirect[*].self_link)
}

# HTTPS proxy when ssl is true
resource "google_compute_target_https_proxy" "default" {
project = var.project
count = var.ssl ? 1 : 0
name = "${var.name}-https-proxy"
name = "${var.name_prefixes.target_https_proxy != null ? var.name_prefixes.target_https_proxy : var.name}${var.name_suffixes.target_https_proxy}"
url_map = local.url_map

ssl_certificates = compact(concat(var.ssl_certificates, google_compute_ssl_certificate.default[*].self_link, google_compute_managed_ssl_certificate.default[*].self_link, ), )
Expand Down Expand Up @@ -153,7 +153,7 @@ resource "google_compute_managed_ssl_certificate" "default" {
provider = google-beta
project = var.project
count = var.ssl && length(var.managed_ssl_certificate_domains) > 0 ? 1 : 0
name = var.random_certificate_suffix == true ? random_id.certificate[0].hex : "${var.name}-cert"
name = var.random_certificate_suffix == true ? random_id.certificate[0].hex : "${var.name_prefixes.certificate != null ? var.name_prefixes.certificate : var.name}${var.name_suffixes.certificate}"

lifecycle {
create_before_destroy = true
Expand All @@ -168,14 +168,14 @@ resource "google_compute_url_map" "default" {
provider = google-beta
project = var.project
count = var.create_url_map ? 1 : 0
name = "${var.name}-url-map"
name = "${var.name_prefixes.url_map != null ? var.name_prefixes.url_map : var.name}${var.name_suffixes.url_map}"
default_service = google_compute_backend_service.default[keys(var.backends)[0]].self_link
}

resource "google_compute_url_map" "https_redirect" {
project = var.project
count = var.https_redirect ? 1 : 0
name = "${var.name}-https-redirect"
name = "${var.name_prefixes.url_map_https_redirect != null ? var.name_prefixes.url_map_https_redirect : var.name}${var.name_suffixes.url_map_https_redirect}"
default_url_redirect {
https_redirect = true
redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
Expand All @@ -188,7 +188,7 @@ resource "google_compute_backend_service" "default" {
for_each = var.backends

project = coalesce(each.value["project"], var.project)
name = "${var.name}-backend-${each.key}"
name = "${var.name_prefixes.backend_service != null ? var.name_prefixes.backend_service : "${var.name}-backend-"}${each.key}${var.name_suffixes.backend_service}"

load_balancing_scheme = var.load_balancing_scheme

Expand Down Expand Up @@ -395,7 +395,7 @@ resource "google_compute_health_check" "default" {
provider = google-beta
for_each = local.health_checked_backends
project = coalesce(each.value["project"], var.project)
name = "${var.name}-hc-${each.key}"
name = "${var.name_prefixes.health_check != null ? var.name_prefixes.health_check : "${var.name}-hc"}-${each.key}${var.name_suffixes.health_check}"

check_interval_sec = lookup(each.value["health_check"], "check_interval_sec", 5)
timeout_sec = lookup(each.value["health_check"], "timeout_sec", 5)
Expand Down Expand Up @@ -504,7 +504,7 @@ resource "google_compute_health_check" "default" {
resource "google_compute_firewall" "default-hc" {
count = length(var.firewall_networks)
project = length(var.firewall_networks) == 1 && var.firewall_projects[0] == "default" ? var.project : var.firewall_projects[count.index]
name = "${var.name}-hc-${count.index}"
name = "${var.name_prefixes.health_check != null ? var.name_prefixes.health_check : "${var.name}-hc"}${var.name_suffixes.health_check}-${count.index}"
network = var.firewall_networks[count.index]
source_ranges = [
"130.211.0.0/22",
Expand Down
44 changes: 42 additions & 2 deletions autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ variable "backends" {
description = optional(string)
enable_cdn = optional(bool)
compression_mode = optional(string)
security_policy = optional(string,null)
edge_security_policy = optional(string,null)
security_policy = optional(string, null)
edge_security_policy = optional(string, null)
custom_request_headers = optional(list(string))
custom_response_headers = optional(list(string))

Expand Down Expand Up @@ -366,3 +366,43 @@ variable "http_keep_alive_timeout_sec" {
type = number
default = null
}

variable "name_suffixes" {
description = "Map of suffixes to the created resource names."
type = object({
address = optional(string, "-address")
address_ipv6 = optional(string, "-ipv6-address")
certificate = optional(string, "-cert")
http_forwarding_rule = optional(string, "")
http_ipv6_forwarding_rule = optional(string, "-ipv6-http")
https_forwarding_rule = optional(string, "-https")
https_ipv6_forwarding_rule = optional(string, "-ipv6-https")
target_http_proxy = optional(string, "-http-proxy")
target_https_proxy = optional(string, "-https-proxy")
url_map = optional(string, "-url-map")
url_map_https_redirect = optional(string, "-https-redirect")
backend_service = optional(string, "")
health_check = optional(string, "")
})
default = {}
}

variable "name_prefixes" {
description = "Map of resource name prefixes allowing name customization. `null` values fallback to module defaults."
type = object({
address = optional(string, null)
address_ipv6 = optional(string, null)
certificate = optional(string, null)
http_forwarding_rule = optional(string, null)
http_ipv6_forwarding_rule = optional(string, null)
https_forwarding_rule = optional(string, null)
https_ipv6_forwarding_rule = optional(string, null)
target_http_proxy = optional(string, null)
target_https_proxy = optional(string, null)
url_map = optional(string, null)
url_map_https_redirect = optional(string, null)
backend_service = optional(string, null)
health_check = optional(string, null)
})
default = {}
}
Loading