Skip to content

Quiz — Resources, Data Sources, State, Lifecycle & Surgery

Quiz results are saved to your browser's local storage and will persist between sessions.

The apply model — what Terraform owns vs reads, non-atomic applies, missing state vs missing resources, lifecycle meta-arguments, state surgery (mv, rm, import), and state security. Reference: §2 State & Backends, §3 Identity & Lifecycle, §8 Data Sources, and §9 State Surgery.

12 questions. Back to all topics

#

If a data block references a real cloud resource, and someone deletes that resource outside Terraform entirely, what happens on the next terraform plan?

#

During terraform apply, 6 of 7 planned resources succeed and 1 fails with an unrelated error (e.g. a network timeout on an external API call). What state are the 6 successful resources in afterward?

#

Compared to a resource block, which of the following is true of a data block?

#

A terraform apply fails partway through creating a cloud resource (e.g. a GKE cluster) due to an unrelated error. The next apply attempt fails with 'Already exists' because the resource is now real in the cloud but absent from Terraform state. What's the right general decision criterion for import vs delete-and-recreate?

#

terraform apply fails on a resource with a transient network error (e.g. TLS handshake timeout) on a follow-up API read, right after the resource's creation call. What should you check before deciding whether to retry, import, or delete-and-recreate?

#

You delete terraform.tfstate (or run terraform state rm) while the real resource still exists, and then run terraform apply. How does the behavior differ between local_file and google_service_account?

#

A GCS bucket was created manually in us-central1. You write a resource "google_storage_bucket" "b" block in HCL with location = "US" and run terraform import google_storage_bucket.b my-bucket. What happens?

#

You rename resource "google_service_account" "gsa" to resource "google_service_account" "backend_sa" in a shared Git repository. What is the difference between fixing this with terraform state mv vs. adding a moved {} block in HCL?

#

A google_service_account has lifecycle { prevent_destroy = true }. You do NOT run terraform destroy; instead, you change its account_id attribute in main.tf and run terraform plan. What happens?

#

When is lifecycle { ignore_changes = [...] } the right architectural choice, and what happens if you write ignore_changes = [tags] on a local_file resource?

#

Why can adding lifecycle { create_before_destroy = true } to a google_service_account with a static account_id = "acme-backend" cause replacement to fail?

#

You want developers to be able to run terraform plan from their laptops against the production GCS state backend, but you do NOT want them to be able to read production secrets stored in terraform.tfstate. Which GCP IAM role accomplishes this?

Quiz Progress

0 / 0 questions answered (0%)

0 correct