InT*_*ons 3 google-bigquery terraform
我知道我们可以在 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
}
Run Code Online (Sandbox Code Playgroud)
所以基本上我要问的是如何将架构部分移动到单独的文件并在运行时 TF 导入它。
如果架构不会动态生成,那么您可以使用该file 函数来实现此目的:
schema = file("${path.module}/nested_path_to/schema.json")
Run Code Online (Sandbox Code Playgroud)
架构.json:
[
{
"name": "permalink",
"type": "STRING",
"mode": "NULLABLE",
"description": "The Permalink"
}
]
Run Code Online (Sandbox Code Playgroud)
如果架构将动态生成,那么您应该使用该templatefile 函数来实现此目的:
schema = templatefile("${path.module}/nested_path_to/schema.json.tmpl", { variable_name = variable_value } )
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2227 次 |
| 最近记录: |