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

group_by inheritance lost when policy nesting too deep #2017

Open
georgivalentinov opened this issue Feb 2, 2025 · 1 comment
Open

group_by inheritance lost when policy nesting too deep #2017

georgivalentinov opened this issue Feb 2, 2025 · 1 comment

Comments

@georgivalentinov
Copy link

georgivalentinov commented Feb 2, 2025

Terraform Version

1.9.4

Terraform Grafana Provider Version

3.18.2

Grafana Version

11.3.1

Affected Resource(s)

  • grafana_notification_policy

Terraform Configuration Files

resource "grafana_notification_policy" "default" {
  contact_point = "main"
  group_by      = ["..."]

  policy {
    policy {
      policy {
        policy {
        }
      }
    }
  }
}

Expected Behavior

Resource to be accepted withour errors. The same policy structure, defined via Grafana's web UI, is accepted and valid.

Actual Behavior

Terraform's plan returns an error:

The argument "group_by" is required, but no definition was found.

Steps to Reproduce

  1. terraform plan

Important Factoids

This is the structure that Grafana's export to Terraform/HCL produces as well. So passing a similar policy to Terraform yields the that error.

Explicitly/manually adding group_by in the deepest policy instance makes the resource valid and Terraform accepts it:

resource "grafana_notification_policy" "default" {
  contact_point = "main"
  group_by      = ["..."]

  policy {
    policy {
      policy {
        policy {
          group_by = ["..."]
        }
      }
    }
  }
}

Doing one level less nesting also seems to be valid:

resource "grafana_notification_policy" "default" {
  contact_point = "main"
  group_by      = ["..."]

  policy {
    policy {
      policy {
      }
    }
  }
}

References

No response

@cindy cindy added this to Alerting Feb 4, 2025
@JacobsonMT
Copy link
Member

Hi @georgivalentinov, it looks like there is a max depth of 4 in the TF model for policies. There is definitely something to improve here, though it's no entire clear exactly what that should be right now:

  • Improve documentation.
  • Clearer error when trying to nest past 4.
  • Grafana API likely exports to TF with >4 nested policies possible.
  • Allow more than 4 nested policies.

@JacobsonMT JacobsonMT moved this to Backlog in Alerting Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

2 participants