Description
TL;DR
I would like to be able to ignore changes to the URL_MAP when adding some new route paths.
This is because I manage my load balancer via terraform, but I am dynamically managing some routes using the gcloud CLI, and dont want to override my existing rules when applying my terraform.
Terraform Resources
Add this in in https://github.com/terraform-google-modules/terraform-google-lb-http/blob/main/modules/serverless_negs/main.tf
lifecycle {
ignore_changes = [
host_rule,
path_matcher,
]
}
In this block:
resource "google_compute_url_map" "default" {
provider = google-beta
project = var.project
count = var.create_url_map ? 1 : 0
name = "${var.name}-url-map"
default_service = google_compute_backend_service.default[keys(var.backends)[0]].self_link
}
Detailed design
This is because terraform doesnt support lifecycle rules at module level.
A solution would be to implement a param: ignore_url_map_changes : bool
, and add the above block if true.
Something like : (not tested)
resource "google_compute_url_map" "default" {
provider = google-beta
project = var.project
count = var.create_url_map ? 1 : 0
name = "${var.name}-url-map"
default_service = google_compute_backend_service.default[keys(var.backends)[0]].self_link
lifecycle {
ignore_changes = var.ignore_url_map_changes ? [
host_rule,
path_matcher,
] : []
}
}
Additional information
I know the module supports the possibility to create a custom url_map and specify it, but it is not really clear to me how I should do it since both URL_map and the serverless_neg module require a default backend.
And it would be the same URL_map with my ignore parameters, and ill be dealing with two backends, and will also need to recreate all my routes.
So it would be useful if a simple ignore param based on a variable could be added.
Thanks for the help!