【发布时间】:2021-07-21 12:34:06
【问题描述】:
我在本地使用 for_each,在 bigquery 中创建倍数数据集。 另一个 for_each 用于创建表,在以前的数据集中。
问题是我必须使用 dataset_ressource.dataset_id.id 等数据集引用表,但我使用 each.value.dataset1。
所以,它只有在我运行“terraform apply”两次时才有效
locals {
bq_settings = {
"${var.dataset1}" = {description = "description dataset 1"},
}
}
locals {
table_settings = {
"${var.table1}" = {dataset_id = "dataset1_test", file = "table1.json"},
}
}
resource "google_bigquery_dataset" "map" {
for_each = local.bq_settings
dataset_id = each.key
description = each.value.description
location = var.location
default_table_expiration_ms = 3600000
labels = {
env = "default"
}
}
resource "google_bigquery_table" "map" {
for_each = local.table_settings
dataset_id = each.value.dataset_id
table_id = each.key
deletion_protection = false
time_partitioning {
type = "DAY"
}
labels = {
env = "default"
}
schema = file("${path.module}/schema-bq/${each.value.file}")
}
```
【问题讨论】:
标签: terraform terraform-provider-gcp terraform0.12+