# 1.3.3 - Terraform Variables

Youtube Video | \~24 min

{% embed url="<https://www.youtube.com/watch?v=PBi0hHjLftk&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=13&pp=iAQB>" %}
<https://www.youtube.com/watch?v=PBi0hHjLftk&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=13&pp=iAQB>
{% endembed %}

:writing\_hand: 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

{% embed url="<https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_dataset#example-usage---bigquery-dataset-basic>" %}
<https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_dataset#example-usage---bigquery-dataset-basic>
{% endembed %}

#### Main.tf

Append info to our previous `main.tf` from 1.3.2

```bash
resource "google_bigquery_dataset" "demo_dataset" {
  dataset_id = "example-dataset"
}
```

:black\_medium\_square: Terminal run `terraform apply`, because we changed our `main.tf` file. You can now see this added into GCP.

#### Variables.tf

```bash
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`

```bash
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

```bash
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:

{% @github-files/github-code-block url="<https://github.com/Tinker0425/de-zoomcamp-my-work/tree/master/module-01/terraform>" %}

:link:  <https://registry.terraform.io/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://data-engineering-zoomcamp-2025-t.gitbook.io/tinker0425/module-1/1.3-setting-up-infrastructure-on-gcp-with-terraform/1.3.3-terraform-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
