-
Notifications
You must be signed in to change notification settings - Fork 133
Description
Terraform currently does not allow variables inside the lifecycle block. For example, this is not allowed:
Copiar
Editar
variable "ignore_changes" {
type = list(string)
default = ["template[0].containers"]
}
resource "google_cloud_run_v2_service" "example" {
name = "example-service"
location = "us-central1"
lifecycle {
ignore_changes = var.ignore_changes
}
}
This results in errors like:
A static list expression is required
Functions or variables may not be called here
Problem:
We cannot dynamically pass values to the lifecycle block via variables. This limits module reusability and makes it difficult to manage resources that are updated outside Terraform. In our case, we maintain separate repositories for application code and infrastructure, and the application pipeline deploys new Docker images directly, so Terraform should not override those updates.
Proposed idea:
Provide a Cloud Run V2 module with the lifecycle block predefined and safe, including the right ignore_changes.
This allows the application code to be deployed via CLI or CI/CD while Terraform continues to manage the infrastructure.
Goal:
Allow modules to safely handle updates outside Terraform without duplicating resources or hardcoding lifecycle values.