Prepare and test your skills
Prepare and test your skills
Free sample question, answered and explained below. The Professional Cloud Architect practice bank has 2,335 more like it. Try 10 free: instant score, no account.
Your organization is designing an Infrastructure as Code (IaC) strategy using Terraform to deploy workloads across multiple Google Cloud environments (dev, qa, and prod). You need to design a scalable and maintainable architecture that adheres to Google Cloud best practices.
Your design must meet the following requirements:
How should you structure your Terraform configuration?
This approach places all Google Cloud resources across all environments (dev, qa, prod) into a single massive root module directory, using local .tfstate files stored and committed directly within the version control system (Git).
terraform plan and terraform apply runs because Terraform refreshes all resources in the state file on every run.You were deploying a temporary single-user prototype on a local workstation that will never be shared, collaborated on, or promoted to production.
modules/ directory that defines variables and outputs without backend or provider blocks, and instantiate it within separate environments/ subdirectories (dev, qa, prod) that each define their own backend.tf and terraform.tfvars.This architecture uses a standard directory separation model that decouples reusable child modules from environment-specific root modules. Common infrastructure resources are defined inside a dedicated modules/ directory, while distinct environment folders (dev, qa, prod) act as independent root execution directories that instantiate the child modules.
terraform.tfvars.backend.tf targeting dedicated Google Cloud Storage (GCS) state prefixes or buckets. This eliminates shared state file risks and reduces the blast radius of changes.terraform_remote_state.required_providers without hardcoding credentials or backend configurations.Separating reusable modules from distinct environment directories is the official standard for enterprise cloud infrastructure. It provides optimal modularity, reliable testing boundaries, and predictable execution plans.
terraform workspace new) combined with ternary expressions checking terraform.workspace against a single backend.This approach uses a single directory with multiple Terraform CLI workspaces (e.g., dev, prod) running against one centralized remote backend. In the configuration files, environment-specific differences are handled using interpolation and ternary conditions based on the built-in variable terraform.workspace (e.g., count = terraform.workspace == "prod" ? 3 : 1).
terraform.workspace makes code harder to read, audit, and refactor as infrastructure complexity grows.A single engineer needed quick, identical ephemeral testing environments that share the exact same configuration and lifecycle without distinct per-environment backend configurations.
provider and backend blocks directly inside each reusable child module, and pass runtime configurations dynamically using CLI command-line parameters (-var='env=prod').This option places provider "google" and backend "gcs" configuration blocks directly inside reusable child modules, then relies on CLI flags (such as -var or -var-file) passed at runtime to differentiate environment values.
-var or -var-file flags is discouraged because CLI arguments are easily omitted, leading to accidental deployments with unintended default values.required_providers blocks.terraform.tfvars files rather than dynamic command-line inputs for predictable execution.Terraform modules were standalone monolithic scripts intended to be invoked only once without being imported as child modules by other configurations.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated