Create BigQuery dataset and table using terraform

Create BigQuery dataset and table using terraform
This is series BigQuery 101. Here in this blogs I am going to build base of our project by creating BigQuery dataset and tables using terraform.
You can also find this code in GitHub
Now before starting terraform code let’s understand dataset and table in BigQuery
As per google cloud a dataset is contained within a specific project. Datasets are top-level containers that are used to organize and control access to your tables and views
And in this blog we are going to use dataset to migrate store tables data and querying
In datasets folder we will have three terraform files main.tf, variable.tf, and output.tf

BigQuery dataset table folder
We will create main.tf, variable.tf, output.tf file on terraform folder In this main file we will have dataset resources to deploy BigQuery dataset, variable file will have variable which are going to be use in building dataset and output file to get dataset id after creating dataset which will be used to create tables
dataset.tf
Deploy dataset to BigQuery
variable.tf
output.tf
Now we will start with table folder

BigQuery table folder
Here we have main.tf and variable.tf
A BigQuery table contains individual records organized in rows. Each record is composed of columns (also called fields).
table.tf
variable.tf
Let’s combine all the resource with building modules.

BigQuery terraform module structure
Here we have main.tf to create terraform modules, variable.tf here we declare all the variables and terraform.tfvars here we pass the value in variables here we can also pass the provider variables :- project_id, region, zone
main.tf
variable.tf
terraform.tfvars
Conclusion
Here In this blog we have successfully deployed BigQuery dataset and table using terraform






