TECHNOLOGIESTieInn Technologies

Building data infrastructure on Google Cloud

Terraform · 14 questions

Short notes

Key idea

A small data platform on Google Cloud is a handful of resources: buckets for raw files, BigQuery datasets and tables, a service account with narrow roles, and maybe Pub/Sub and a scheduler. Terraform builds the whole set the same way every time.

Syntax

resource "google_service_account" "etl" {
  account_id = "etl-runner"
}
resource "google_bigquery_dataset_iam_member" "etl_writes" {
  dataset_id = google_bigquery_dataset.sales.dataset_id
  role       = "roles/bigquery.dataEditor"
  member     = "serviceAccount:${google_service_account.etl.email}"
}
resource "google_project_service" "bq" {
  service = "bigquery.googleapis.com"
}

Example

One config creates raw and curated buckets with lifecycle rules, a sales dataset with a partitioned orders table, an orders Pub/Sub topic, and an etl-runner service account that can write only to sales.

Traps

  • APIs must be enabled (google_project_service) before resources that use them.
  • _iam_policy resources overwrite all bindings; use _iam_member to add one.
  • Changing a table's partitioning forces replacement, which drops the data. Read the plan.
  • Set deletion_protection on BigQuery tables you care about.

Want the full lesson with step-by-step examples, a project and a certificate? Terraform course, ₹120 →

Questions

Open in Code Lab5 free questions
5 questions

    Building data infrastructure on Google Cloud

  1. Question 1medium

    What's the recommended way to let Terraform on your laptop act on Google Cloud?

  2. Building data infrastructure on Google Cloud

  3. Question 2medium

    Why set disable_on_destroy = false on google_project_service?

  4. Building data infrastructure on Google Cloud

  5. Question 3easy

    What does force_destroy = false do on a bucket?

  6. Building data infrastructure on Google Cloud

  7. Question 4medium

    Which nested block moves files to a colder storage class after 30 days?

  8. Building data infrastructure on Google Cloud

  9. Question 5hard

    Your team builds 200 derived tables with dbt. What should Terraform manage?

9 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.