File tree Expand file tree Collapse file tree 6 files changed +23
-3
lines changed
Expand file tree Collapse file tree 6 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ module "load_balancer" {
121121 vpc_id = local. vpc_id
122122 subnetwork = local. vpc_subnetwork
123123 deploy_neg_backend = var. deploy_neg_backend
124+ deploy_lb = var. deploy_lb
124125
125126 depends_on = [
126127 module . project_factory_project_services ,
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ resource "google_compute_managed_ssl_certificate" "lb_app" {
6767}
6868
6969data "google_compute_ssl_certificate" "lb_app" {
70- count = var. ssl_cert_name != " " ? 1 : 0
70+ count = var. deploy_lb && var . ssl_cert_name != " " ? 1 : 0
7171 project = var. project_id
7272 name = var. ssl_cert_name
7373
@@ -81,6 +81,8 @@ module "lb_app" {
8181 source = " GoogleCloudPlatform/lb-http/google"
8282 version = " 12.1.4"
8383
84+ count = var. deploy_lb ? 1 : 0
85+
8486 project = var. project_id
8587 name = " ${ var . deployment_name } -app"
8688 target_tags = [" app" ]
@@ -151,3 +153,7 @@ module "lb_app" {
151153 resource . google_compute_network_endpoint_group . nginx ,
152154 ]
153155}
156+
157+ locals {
158+ external_ip = var. deploy_lb ? module. lb_app [0 ]. external_ip : " 255.255.255.255"
159+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ resource "random_id" "neg_name" {
88}
99
1010resource "google_compute_network_endpoint_group" "nginx" {
11- count = var. deploy_neg_backend ? 1 : 0
11+ count = var. deploy_lb && var . deploy_neg_backend ? 1 : 0
1212
1313 name = local. neg_name
1414 network = var. vpc_id
Original file line number Diff line number Diff line change 11output "lb_external_ip" {
2- value = jsonencode ([module . lb_app . external_ip ])
2+ value = jsonencode ([local . external_ip ])
33}
44
55output "neg_name" {
Original file line number Diff line number Diff line change @@ -87,6 +87,12 @@ variable "deploy_neg_backend" {
8787 description = " Set this to true to connect the backend service to the NEG that the GKE cluster will create"
8888}
8989
90+ variable "deploy_lb" {
91+ type = bool
92+ default = true
93+ description = " Allows a deploy with a not-yet-existing load balancer"
94+ }
95+
9096variable "vpc_id" {
9197 type = string
9298 description = " The ID of the VPC network where the GKE cluster will be created"
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ variable "lb_app_rules" {
122122 src_ip_ranges = list (string ) # optional, only used if match_type is "src_ip_ranges"
123123 expr = string # optional, only used if match_type is "expr"
124124 }))
125+ default = []
125126 description = " Extra rules to apply to the application load balancer for additional filtering"
126127}
127128
@@ -137,6 +138,12 @@ variable "deploy_neg_backend" {
137138 description = " Set this to true to connect the backend service to the NEG that the GKE cluster will create"
138139}
139140
141+ variable "deploy_lb" {
142+ type = bool
143+ default = true
144+ description = " Allows a deploy with a not-yet-existing load balancer"
145+ }
146+
140147# ╻ ╻┏━┓┏━╸
141148# ┃┏┛┣━┛┃
142149# ┗┛ ╹ ┗━╸
You can’t perform that action at this time.
0 commit comments