Hi @apparentlymart , i am trying to automate Newrelic dashboard creation using Terrfaorm.Currently having issue with nested loops while making widgets dynamic.Can you help on it.Attaching my variable file and terraform script below.
I get errors with the lines below from DASHBOARD.TF
title = upper(page.value["lines"]["title"][widget_line.key])
query = page.value["lines"]["query"][widget_line.key]
------------------------------------------VARIABLES.TF------------------
variable “pages” {
type = list(object({
pagename = string
lines = list(object({
title = list(string)
query = list(string)
}))
billboards = list(object({
title = list(string)
query = list(string)
}))
}))
}
-------------------------------------------------------DEV.TFVARS-----------------------------------
pages = [{
pagename = “netflix”
lines = [{
query = [“FROM Transaction SELECT rate(count(), 1 minute)"]
title = [“title_1”]
}]
billboards = [ {
query = ["FROM Transaction SELECT rate(count(), 1 minute)”]
title = [“title_2”]
} ]
}]
--------------------------------------DASHBOARD.TF----------------------------
resource “newrelic_one_dashboard” “exampledash” {
name = “New Relic Terraform Example”
permissions = “public_read_write”
dynamic “page” {
for_each = var.pages
content {
name = page.value[“pagename”]
dynamic “widget_line” {
for_each = page.value[“lines”]
content {
title = upper(page.value[“lines”][“title”][widget_line.key])
row = 1
column = 1
width = 6
height = 3
nrql_query {
query = page.value[“lines”][“query”][widget_line.key]
}
}
}
}
}
}