Skip to content

Instantly share code, notes, and snippets.

@tdigangi
Last active August 9, 2019 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdigangi/84c4e963f19d67742099396d6064459b to your computer and use it in GitHub Desktop.
Save tdigangi/84c4e963f19d67742099396d6064459b to your computer and use it in GitHub Desktop.
bq medium article gists
provider "google" {
version = "~> 2.5.0"
credentials = file("/path/to/.ssh/bq-key.json") # Update this to the correct location
}
module "bigquery" {
source = "terraform-google-modules/bigquery/google" # Path to the
version = "~> 2.0.0" # Specify the version of the module you require
dataset_id = "foo"
dataset_name = "foo"
description = "some description" # updated the description accordingly
expiration = var.expiration
project_id = var.project_id
location = "US" # Update location if needed
tables = var.tables
time_partitioning = var.time_partitioning
dataset_labels = var.dataset_labels
}
output "dataset_id" {
value = module.bigquery.dataset_id
description = "Unique id for the dataset being provisioned"
}
output "dataset_name" {
value = module.bigquery.dataset_name
description = "Friendly name for the dataset being provisioned"
}
output "dataset_project" {
value = module.bigquery.dataset_project
description = "Project where the dataset and table are created"
}
output "table_id" {
value = module.bigquery.table_id
description = "Unique id for the table being provisioned"
}
output "table_name" {
value = module.bigquery.table_name
description = "Friendly name for the table being provisioned"
}
output "dataset_labels" {
value = module.bigquery.dataset_labels
description = "Key value pairs in a map for dataset labels"
}
output "table_labels" {
value = module.bigquery.table_labels
description = "Key value pairs in a map for table labels"
}
#Update with the project you are deploying module to
project_id = "example-project"
#Time that
time_partitioning = "DAY"
#The labels for dataset being deployed
dataset_labels = {
env = "dev"
billable = "true"
owner = "janesmith"
}
#List of the tables that you are
tables = [
{
table_id = "foo",
schema = "sample_bq_schema.json",
labels = {
env = "dev"
billable = "true"
owner = "joedoe"
},
},
]
variable "expiration" {
description = "TTL of tables using the dataset in MS"
default = null
}
variable "project_id" {
description = "Project wheree the dataset and table are created"
}
variable "time_partitioning" {
description = "Configures time-based partitioning for this table"
}
variable "dataset_labels" {
description = "A mapping of labels to assign to the table"
type = map(string)
}
variable "tables" {
description = "A list of maps that includes both table_id and schema in each element, the table(s) will be created on the single dataset"
default = []
type = list(object({
table_id = string,
schema = string,
labels = map(string),
}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment