Skip to content

Commit d4fba67

Browse files
committed
feat: added support for creating proxy only subnet
1 parent e70f5d4 commit d4fba67

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

modules/frontend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This module creates `HTTP(S) forwarding rule` and its dependencies. This modules
1919
| http\_port | The port for the HTTP load balancer | `number` | `80` | no |
2020
| https\_port | The port for the HTTPS load balancer | `number` | `443` | no |
2121
| https\_redirect | Set to `true` to enable https redirect on the lb. | `bool` | `false` | no |
22-
| internal\_forwarding\_rules\_config | List of internal managed forwarding rules config. One of 'address' or 'subnetwork' is required for each. It is only applicable for internal load balancer | <pre>list(object({<br> region = string<br> address = optional(string)<br> subnetwork = optional(string)<br> }))</pre> | `[]` | no |
22+
| internal\_forwarding\_rules\_config | List of internal managed forwarding rules config. One of 'address' or 'subnetwork' is required for each. If 'create\_proxy\_only\_subnet' is true, 'proxy\_only\_subnet\_ip' is required. It is only applicable for internal load balancer. | <pre>list(object({<br> region = string<br> address = optional(string)<br> subnetwork = optional(string)<br> create_proxy_only_subnet = bool<br> proxy_only_subnet_ip = optional(string)<br> }))</pre> | `[]` | no |
2323
| ipv6\_address | An existing IPv6 address to use (the actual IP address value) | `string` | `null` | no |
2424
| labels | The labels to attach to resources created by this module | `map(string)` | `{}` | no |
2525
| load\_balancing\_scheme | Load balancing scheme type (EXTERNAL for classic external load balancer, EXTERNAL\_MANAGED for Envoy-based load balancer, INTERNAL\_MANAGED for internal load balancer and INTERNAL\_SELF\_MANAGED for traffic director) | `string` | `"EXTERNAL_MANAGED"` | no |

modules/frontend/main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ locals {
4343
first_backend_service = try(local.backend_services_by_host[local.first_host][local.first_path], null)
4444
}
4545

46+
resource "google_compute_subnetwork" "proxy_only" {
47+
for_each = {
48+
for index, config in var.internal_forwarding_rules_config : index => config
49+
if config.create_proxy_only_subnet == true
50+
}
51+
52+
name = "${var.name}-proxy-only-subnet-${each.value.region}"
53+
ip_cidr_range = each.value.proxy_only_subnet_ip
54+
network = var.network
55+
purpose = "GLOBAL_MANAGED_PROXY"
56+
region = each.value.region
57+
project_id = var.project_id
58+
role = "ACTIVE"
59+
}
60+
61+
4662
### IPv4 block ###
4763
resource "google_compute_global_forwarding_rule" "http" {
4864
provider = google-beta

modules/frontend/metadata.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,14 @@ spec:
188188
description: Specifies how long to keep a connection open, after completing a response, while there is no matching traffic (in seconds).
189189
varType: number
190190
- name: internal_forwarding_rules_config
191-
description: List of internal managed forwarding rules config. One of 'address' or 'subnetwork' is required for each. It is only applicable for internal load balancer
191+
description: List of internal managed forwarding rules config. One of 'address' or 'subnetwork' is required for each. If 'create_proxy_only_subnet' is true, 'proxy_only_subnet_ip' is required. It is only applicable for internal load balancer.
192192
varType: |-
193193
list(object({
194-
region = string
195-
address = optional(string)
196-
subnetwork = optional(string)
194+
region = string
195+
address = optional(string)
196+
subnetwork = optional(string)
197+
create_proxy_only_subnet = bool
198+
proxy_only_subnet_ip = optional(string)
197199
}))
198200
defaultValue: []
199201
outputs:

modules/frontend/variables.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,13 @@ variable "http_keep_alive_timeout_sec" {
200200
}
201201

202202
variable "internal_forwarding_rules_config" {
203-
description = "List of internal managed forwarding rules config. One of 'address' or 'subnetwork' is required for each. It is only applicable for internal load balancer"
203+
description = "List of internal managed forwarding rules config. One of 'address' or 'subnetwork' is required for each. If 'create_proxy_only_subnet' is true, 'proxy_only_subnet_ip' is required. It is only applicable for internal load balancer."
204204
type = list(object({
205-
region = string
206-
address = optional(string)
207-
subnetwork = optional(string)
205+
region = string
206+
address = optional(string)
207+
subnetwork = optional(string)
208+
create_proxy_only_subnet = bool
209+
proxy_only_subnet_ip = optional(string)
208210
}))
209211
default = []
210212
}

0 commit comments

Comments
 (0)