Hey All, has anyone tried to use the data template_file with google_monitoring_dashboard resource?
Here is what I am trying to do.
Basically we want to create a dashboard template for our pubsub subscriptions, this template would take 1 or many subs (It's up to the user to pass to the module).
Here is my header template.
"displayName": "${dash_name}",
"gridLayout": {
"columns": "2",
"widgets": [
${chart_output}
]
}
}
Basic chart template.
"title": "Unread Messages",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"minAlignmentPeriod": "60s",
"plotType": "LINE",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [
"resource.label.\"subscription_id\""
],
"perSeriesAligner": "ALIGN_SUM"
},
},
"unitOverride": "1"
}
}
],
"timeshiftDuration": "0s",
"yAxis": {
"label": "y1Axis",
"scale": "LINEAR"
}
}
Code:
resource "google_monitoring_dashboard" "pubsub-overview" {
dashboard_json = data.template_file.header_chart.rendered
}
data template_file "header_chart" {
template = "{${file("${path.module}/templates/header.tmpl")}"
vars = {
dash_name = var.dash_name
chart_output = jsonencode(join("\n" ,data.template_file.pubsub_chart.*.rendered))
}
}
data template_file "pubsub_chart" {
template = "{${file("${path.module}/templates/charts2.tmpl")}"
vars = {
sub_name = "${var.sub_name}"
}
}
Here is the error I am getting:
google_monitoring_dashboard.pubsub-overview: Creating...
Thanks!