【发布时间】:2022-01-07 17:00:50
【问题描述】:
是否可以包含要从远程文件注入的部分资源定义?例如,我通过使用页面 {} 块定义仪表板中包含的每个页面来使用 https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/one_dashboard 创建仪表板。
在下面的示例中,我在资源 {} 下有三个页面定义。是否可以替换我的每个或所有页面 {} 块定义以从远程文件获取内容?
预期定义
resource "newrelic_one_dashboard" "exampledash" {
name = "New Relic Terraform Example with three pages"
page {
// reference to remote file with contents for page 1
}
page {
// reference to remote file with contents for page 2
}
page {
// reference to remote file with contents for page 3
}
}
OR
resource "newrelic_one_dashboard" "exampledash" {
name = "New Relic Terraform Example with three pages"
// reference to remote file with all page {} definitions
}
实际定义
resource "newrelic_one_dashboard" "exampledash" {
name = "New Relic Terraform Example with three pages"
page {
name = "Page1"
widget_bar {
title = "Average transaction duration, by application"
row = 1
column = 1
nrql_query {
account_id = var.account_id
query = "FROM Transaction SELECT count(1) FACET appName"
}
filter_current_dashboard = true
}
widget_line {
title = "response time view"
row = 2
column = 1
width = 4
height = 4
# drilldown_dashboard_id = self.id
nrql_query {
account_id = var.account_id
query = "FROM Transaction SELECT average(duration) FACET appName"
}
}
}
page {
name = "Page2"
widget_bar {
title = "Average transaction duration, by application"
row = 1
column = 1
nrql_query {
account_id = var.account_id
query = "FROM Transaction SELECT count(1) FACET appName"
}
filter_current_dashboard = true
}
widget_line {
title = "response time view"
row = 2
column = 1
width = 4
height = 4
# drilldown_dashboard_id = self.id
nrql_query {
account_id = var.account_id
query = "FROM Transaction SELECT average(duration) FACET appName"
}
}
}
page {
name = "Page3"
widget_bar {
title = "Average transaction duration, by application"
row = 1
column = 1
nrql_query {
account_id = var.account_id
query = "FROM Transaction SELECT count(1) FACET appName"
}
filter_current_dashboard = true
}
widget_line {
title = "response time view"
row = 2
column = 1
width = 4
height = 4
# drilldown_dashboard_id = self.id
nrql_query {
account_id = var.account_id
query = "FROM Transaction SELECT average(duration) FACET appName"
}
}
}
}
期待
【问题讨论】:
-
不在 TF 中。也许使用 Terragrunt 你可以做到这一点。
标签: terraform newrelic terraform-template-file