Quiz results are saved to your browser's local storage and will persist between sessions.
How the google provider authenticates, required_providers vs provider {}, version constraints (~>), lock files, provider aliasing, and backend initialization. Reference: §1 Execution Model & Providers and §2 State & Backends.
What does gcloud auth application-default login actually create, and where?
It writes an OAuth refresh token to that file. Terraform's google provider and any Google client library read it automatically. The derived access token expires hourly, but the refresh token doesn't — you authenticate once and forget about it until you explicitly revoke it.
Does terraform init create or touch terraform.tfstate?
init only downloads provider plugins into .terraform/, configures the backend, and writes .terraform.lock.hcl. It is purely tooling setup — safe to rerun anywhere, zero effect on real infrastructure or state.
A provider block sets project=var.project_id, but every resource in the module also sets its own explicit project=var.project_id. What happens if you delete the provider block's project line entirely?
Provider-block project/region/zone are fallback defaults only, used exclusively by resources that don't set their own. If every resource sets its own value explicitly, the provider block's value is dead code — removing it changes nothing.
What's the actual difference between the required_providers block in a terraform{} block and a provider "google" {} config block?
required_providers (in the terraform block) is what init reads to know which provider plugin to fetch. The provider block itself is only about how that plugin authenticates and what defaults it applies at plan/apply time.
Why is data "google_client_config" used to supply the GCP access token to downstream providers (kubernetes, helm), rather than a resource or a static/stored value?
GCP access tokens expire hourly. A data source re-queries live on every single plan/apply, guaranteeing that kubectl/Helm always receive a fresh, valid token instead of a cached expired one.
What is the exact difference between the version constraints version = "~> 2.4.1" and version = "~> 2.4"?
With the pessimistic constraint operator (~>), only the right-most specified version component is allowed to increment. Misplacing the last digit is how unexpected minor or major provider upgrades slip in during init -upgrade.
Why should .terraform.lock.hcl be committed to Git in production repositories while .terraform/ is gitignored, and why must a teammate still run terraform init after cloning?
The version constraint in .tf expresses acceptable range (intent), while .terraform.lock.hcl records the exact resolved version (fact). Plain terraform init honors the lock file and downloads the matching binary for the caller's OS into .terraform/; only terraform init -upgrade moves the locked version.
You define a secondary provider block provider "google" { alias = "us_east" ... } in your root module and call a child module module"east_storage" { source = "./modules/storage" }. How does the child module use the us_east provider?
Child modules never inherit aliased providers implicitly and should never contain their own hardcoded provider {} configuration blocks (which makes them non-reusable). Passing providers = { google = google.us_east } maps the child module's default google reference to the parent's google.us_east configuration.
Why can't a Terraform configuration create the GCS bucket defined in its own backend "gcs" {} block, and what happens if you use a partial backend "gcs" {} block and forget to pass -backend-config during terraform init?
init sets up state storage before the resource graph is ever built, and backend {} blocks cannot interpolate variables or resource attributes. And when -backend-config="bucket=..." is omitted, Terraform sends an empty bucket string to the GCS API, returning storage: bucket doesn't exist ... 404 rather than a syntax error.
terraform apply on a google_storage_bucket fails with Error412:constraints/storage.uniformBucketLevelAccess. What does this error mean and what is the fix?
Provider defaults do not always match your organization's security guardrails. An Error 412 mentioning constraints/... is a GCP Organization Policy rejection, fixed by explicitly setting the required attribute (uniform_bucket_level_access = true) in HCL.