0
0
GCPcloud~20 mins

Terraform GCP provider setup - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform GCP Provider Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Configuration
intermediate
2:00remaining
Correct GCP provider block for Terraform
Which Terraform provider block correctly configures the Google Cloud provider with a specific project and region?
A
provider "google" {
  project = "my-project-id"
  region  = "us-central1"
}
B
provider "gcp" {
  project = "my-project-id"
  region  = "us-central1"
}
C
provider "google" {
  project_id = "my-project-id"
  location  = "us-central1"
}
D
provider "google" {
  project = "my-project-id"
  zone  = "us-central1"
}
Attempts:
2 left
💡 Hint
The official Terraform provider for Google Cloud is named "google" and uses "project" and "region" keys.
service_behavior
intermediate
2:00remaining
Effect of missing credentials in GCP provider
What happens when you run Terraform with a GCP provider block that does not specify credentials and no environment variables are set?
ATerraform ignores authentication and creates resources anonymously.
BTerraform fails with an authentication error indicating missing credentials.
CTerraform applies resources successfully using default application credentials.
DTerraform prompts interactively for credentials during apply.
Attempts:
2 left
💡 Hint
Terraform requires credentials to authenticate with GCP APIs unless default credentials are available.
Architecture
advanced
2:30remaining
Best practice for managing multiple GCP projects in Terraform
You manage infrastructure across multiple GCP projects. Which Terraform setup best isolates configurations and credentials per project?
AUse a single Terraform configuration with multiple provider aliases, each configured with its project and credentials.
BUse one provider block with the first project and switch the project ID manually before each apply.
CCreate separate Terraform workspaces for each project but use the same provider block without aliases.
DUse one provider block and pass project IDs as variables without changing credentials.
Attempts:
2 left
💡 Hint
Terraform provider aliases allow multiple configurations in one setup.
security
advanced
2:30remaining
Secure way to provide GCP credentials to Terraform
Which method is the most secure way to provide GCP credentials to Terraform for automated pipelines?
ACommit the service account JSON key file to the source code repository and reference it in Terraform provider.
BManually enter credentials in Terraform provider block as plain text.
CStore the service account JSON key file in the pipeline environment variables as a base64 string and decode it at runtime.
DUse Google Cloud Workload Identity Federation to authenticate without storing keys.
Attempts:
2 left
💡 Hint
Avoid storing long-lived keys in source code or environment variables when possible.
🧠 Conceptual
expert
3:00remaining
Terraform provider version constraint impact
Given this provider block snippet, what is the effect of the version constraint on Terraform provider behavior? provider "google" { version = ">= 4.0, < 5.0" project = "my-project" region = "us-east1" }
GCP
provider "google" {
  version = ">= 4.0, < 5.0"
  project = "my-project"
  region  = "us-east1"
}
ATerraform will fail to initialize because the version constraint syntax is invalid.
BTerraform will use any provider version including 5.0 and above if available.
CTerraform will only use provider versions 4.x, preventing automatic upgrades to version 5 or higher.
DTerraform ignores the version constraint and uses the latest installed provider.
Attempts:
2 left
💡 Hint
Version constraints control which provider versions Terraform can install and use.