Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lifecycle ignore changes param for serverless_negs/url_maps #481

Open
clement-chaneching opened this issue Jan 10, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@clement-chaneching
Copy link

clement-chaneching commented Jan 10, 2025

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!

@clement-chaneching clement-chaneching added the enhancement New feature or request label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant