1.3.3 - Terraform Variables
Last updated Jan 25, 2025
Youtube Video | ~24 min
✍️ In this video we will continue talking about terraform main.tf and now variable.tf. We will also learn about Big Query Datasets and using function file().
Terraform Big Query Dataset
Main.tf
Append info to our previous main.tf
from 1.3.2
resource "google_bigquery_dataset" "demo_dataset" {
dataset_id = "example-dataset"
}
◼️ Terminal run terraform apply
, because we changed our main.tf
file. You can now see this added into GCP.
Variables.tf
variable "bq_dataset_name" {
description = "My BigQuery Dataset Name"
#Update the below to what you want your dataset to be called
default = "demo_dataset"
}
To use your variables.tf
, we will need to modify the main.tf
resource "google_bigquery_dataset" "demo_dataset" {
dataset_id = var.bq_dataset_name
location = var.location
}
Another example you cn add is using function file() in your variables.tf
scripts
variable "credentials" {
description = "My Credentials"
default = "<Path to your Service Account json file>"
#ex: if you have a directory where this file is called keys with your service account json file
#saved there as my-creds.json you could use default = "./keys/my-creds.json"
}
Resources
Full terraform code here:
Not found
Last updated