【发布时间】:2020-06-28 05:31:51
【问题描述】:
我正在尝试使用 terraform 部署 BigQuery 计划查询,但我不知道如何使用 list 和 for_each 语法。
我有这个模板文件。
SELECT *
FROM mydataset.mytable_${suffix}
然后使用 template_file 模块生成查询列表。 var.suffix_list 这里是一个字符串列表。
data "template_file" "query" {
for_each = var.suffix_list # list(string)
template = "file/path/to/template/file"
vars = {
suffix = each.value
}
}
我想从这个模块生成一个查询列表。
output "query" {
value = # a list of rendered query
}
此输出将是google_bigquery_data_transfer_config 资源的输入。
resource "google_bigquery_data_transfer_config" "query_config" {
for_each = # a list of rendered query
data_refresh_window_days = var.data_refresh_window_days
data_source_id = "scheduled_query"
display_name = var.display_name
disabled = var.disabled
destination_dataset_id = var.destination_dataset_id
location = var.query_location
project = var.gcp_project
schedule = var.query_schedule
params = {
destination_table_name_template = var.destination_table_name_template
query = each.value
}
}
如何输出google_bigquery_data_transfer_config 的定义和输入?
提前致谢。
【问题讨论】:
标签: terraform terraform-provider-gcp