> For the complete documentation index, see [llms.txt](https://data-engineering-zoomcamp-2025-t.gitbook.io/tinker0425/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](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).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` 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>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
