gpt4 book ai didi

google-bigquery - 单独的 JSON 文件中的 Terraform Bigquery 表架构

转载 作者:行者123 更新时间:2023-12-02 16:02:00 24 4
gpt4 key购买 nike

我知道我们可以在 Terraform 文件中定义表架构。我的问题是,有没有一种方法可以在单独的文件中定义模式,然后 Terraform 在运行时将其导入。这样它将提供更好的管理和可读性

 resource "google_bigquery_table" "default" {
dataset_id = google_bigquery_dataset.default.dataset_id
table_id = "bar"

time_partitioning {
type = "DAY"
}

labels = {
env = "default"
}

**schema = <<EOF
[
{
"name": "permalink",
"type": "STRING",
"mode": "NULLABLE",
"description": "The Permalink"
}
]**
EOF

}

所以基本上我要问的是如何将模式部分移动到单独的文件并在运行时 TF 导入它。

最佳答案

如果模式不会动态生成,那么您可以使用文件 function为此目的:

schema = file("${path.module}/nested_path_to/schema.json")

架构.json:

[
{
"name": "permalink",
"type": "STRING",
"mode": "NULLABLE",
"description": "The Permalink"
}
]

如果模式将动态生成,那么您应该使用模板文件 function为此目的:

schema = templatefile("${path.module}/nested_path_to/schema.json.tmpl", { variable_name = variable_value } )

关于google-bigquery - 单独的 JSON 文件中的 Terraform Bigquery 表架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70425085/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com