0

The thing is I know Terraform ignore_changes block only supports static lists or in another words, static indices mapping to items. Secondly, I need to be able to ignore specific metadata based on a regex.

I tried to use a local value and then use it in a list but it returned with the same error.

 locals {
   ignore_gke_metadata_changes = [
     for x in google_compute_project_metadata.metadata.metadata : x.key if regex("^gke-dku[0-9]+$", x.key)
   ]
 }

 lifecycle {
   ignore_changes = local.ignore_gke_metadata_changes
 }

Edit:

Here's a sample of the error returned when I try to run a plan:

16:     ignore_changes = local.ignore_gke_metadata_changes
 
A static list expression is required.
3
  • 3
    You cannot do that: developer.hashicorp.com/terraform/language/meta-arguments/…. Commented May 31, 2023 at 12:35
  • @MarkoE Okayy so there's no way or even a workaround to iterate over a list and pass it statically to the lifecycle block? Commented May 31, 2023 at 13:38
  • I don't think so. Commented May 31, 2023 at 13:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.