我正在尝试使用 Terraform从 Google Sheets 摄取数据创建 BQ 表,这里是我的external_data_configuration块
resource "google_bigquery_table" "sheet" {
dataset_id = google_bigquery_dataset.bq-dataset.dataset_id
table_id = "sheet"
external_data_configuration {
autodetect = true
source_format = "GOOGLE_SHEETS"
google_sheets_options {
skip_leading_rows = 1
}
source_uris = [
"https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxx",
]
}
Run Code Online (Sandbox Code Playgroud)
我将文件设为公开,但是当我尝试创建表时出现错误:
错误:googleapi:错误 400:读取表格时出错:工作表,错误消息:无法读取电子表格。错误:未找到具有 Google Drive 范围的 OAuth 令牌。,无效
我阅读了 Terraform文档,似乎我需要在我的provider.tf文件中指定access_token和scopes我只是不知道该怎么做,因为我认为它会与我当前的身份验证方法(服务帐户)冲突
将 scopes 参数添加到您的provider.tf
provider "google" {
credentials = "${file("${var.path}/secret.json")}"
scopes = ["https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/bigquery"]
project = "${var.project_id}"
region = "${var.gcp_region}"
} …
Run Code Online (Sandbox Code Playgroud)