google_bigquery_table

Creates a table resource in a dataset for Google BigQuery. For more information see the official documentation and API.

Example Usage

resource "google_bigquery_dataset" "default" {
  dataset_id                  = "foo"
  friendly_name               = "test"
  description                 = "This is a test description"
  location                    = "EU"
  default_table_expiration_ms = 3600000

  labels = {
    env = "default"
  }
}

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"
  },
  {
    "name": "state",
    "type": "STRING",
    "mode": "NULLABLE",
    "description": "State where the head office is located"
  }
]
EOF

}

resource "google_bigquery_table" "sheet" {
  dataset_id = google_bigquery_dataset.default.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/123456789012345",
    ]
  }
}

Argument Reference

The following arguments are supported:

The external_data_configuration block supports:

The csv_options block supports:

The json_options block supports:

The google_sheets_options block supports:

The hive_partitioning_options block supports:

The avro_options block supports:

The parquet_options block supports:

The time_partitioning block supports:

The range_partitioning block supports:

The range block supports:

The view block supports:

The materialized_view block supports:

The encryption_configuration block supports the following arguments:

The table_constraints block supports:

The primary_key block supports:

The foreign_keys block supports:

The referenced_table block supports:

The column_references block supports:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Import

BigQuery tables can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import BigQuery tables using one of the formats above. For example:

import {
  id = "projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}"
  to = google_bigquery_table.default
}

When using the terraform import command, BigQuery tables can be imported using one of the formats above. For example:

$ terraform import google_bigquery_table.default projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}
$ terraform import google_bigquery_table.default {{project}}/{{dataset_id}}/{{table_id}}
$ terraform import google_bigquery_table.default {{dataset_id}}/{{table_id}}