File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -174,10 +174,29 @@ resource "google_compute_url_map" "https_redirect" {
174174 project = var. project
175175 count = var. https_redirect ? 1 : 0
176176 name = " ${ var . name } -https-redirect"
177- default_url_redirect {
178- https_redirect = true
179- redirect_response_code = " MOVED_PERMANENTLY_DEFAULT"
180- strip_query = false
177+
178+ host_rule {
179+ hosts = length (var. https_redirect_domains ) > 0 ? var. https_redirect_domains : [" *" ]
180+ path_matcher = " https-redirect-matcher"
181+ }
182+ path_matcher {
183+ name = " https-redirect-matcher"
184+ default_url_redirect {
185+ https_redirect = true
186+ redirect_response_code = " MOVED_PERMANENTLY_DEFAULT"
187+ strip_query = false
188+ }
189+ }
190+ default_route_action {
191+ weighted_backend_services {
192+ backend_service = google_compute_backend_service. default [keys (var. backends )[0 ]]. self_link
193+ }
194+ fault_injection_policy {
195+ abort {
196+ http_status = 404
197+ percentage = 100
198+ }
199+ }
181200 }
182201}
183202
Original file line number Diff line number Diff line change @@ -275,6 +275,11 @@ variable "https_redirect" {
275275 default = false
276276}
277277
278+ variable "https_redirect_domains" {
279+ type = list (string )
280+ default = []
281+ }
282+
278283variable "random_certificate_suffix" {
279284 description = " Bool to enable/disable random certificate name generation. Set and keep this to true if you need to change the SSL cert."
280285 type = bool
You can’t perform that action at this time.
0 commit comments