Skip to content

Commit

Permalink
feat: Add support for allowed list of domains for https redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinivas Arnepalli committed Nov 19, 2024
1 parent 279c8e8 commit c40fe62
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
27 changes: 23 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,29 @@ resource "google_compute_url_map" "https_redirect" {
project = var.project
count = var.https_redirect ? 1 : 0
name = "${var.name}-https-redirect"
default_url_redirect {
https_redirect = true
redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
strip_query = false

host_rule {
hosts = var.https_redirect_domains
path_matcher = "https-redirect-matcher"
}
path_matcher {
name = "https-redirect-matcher"
default_url_redirect {
https_redirect = true
redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
strip_query = false
}
}
default_route_action {
weighted_backend_services {
backend_service = google_compute_backend_service.default[keys(var.backends)[0]].self_link
}
fault_injection_policy {
abort {
http_status = 404
percentage = 100
}
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ variable "https_redirect" {
default = false
}

variable "https_redirect_domains" {
type = list(string)
default = []
}

variable "random_certificate_suffix" {
description = "Bool to enable/disable random certificate name generation. Set and keep this to true if you need to change the SSL cert."
type = bool
Expand Down

0 comments on commit c40fe62

Please sign in to comment.