I create module for google cloud load balancer, and confused how to simplified this resource into variable. the resource like this
resource "google_compute_url_map" "urlmap" {
name = "urlmap"
description = "a description"
default_service = google_compute_backend_bucket.static.id
host_rule {
hosts = ["mysite.com"]
path_matcher = "mysite"
}
host_rule {
hosts = ["myothersite.com"]
path_matcher = "otherpaths"
}
path_matcher {
name = "mysite"
default_service = google_compute_backend_bucket.static.id
path_rule {
paths = ["/home"]
service = google_compute_backend_bucket.static.id
}
path_rule {
paths = ["/login"]
service = google_compute_backend_service.login.id
}
path_rule {
paths = ["/static"]
service = google_compute_backend_bucket.static.id
}
}
path_matcher {
name = "otherpaths"
default_service = google_compute_backend_bucket.static.id
}
I want to move host_rule
, path_matcher
, and path_rule
, become variable…
is it correct if i make variable like this:
variable "path_mathcer" {
type = list(object({
name = string\
default_service = (i confused what must be fill in here)
}
{ path_rule = object{
path = list
service = (i confused what must be fill in here)
}
}))
}
variable "host_rules" {
type = list(object({
hosts = list
path_matcher = string
}))
}
and how i call it in resource block?
for path_rule
it can be null or many
Thank you