mediumMultiple ChoiceObjective-mapped
Google ACE Practice Question: A team uses Terraform to manage GCP infrastructure
A team uses Terraform to manage GCP infrastructure. After running `terraform plan`, they see 15 resources to be created. They want to apply only the Cloud SQL instance (resource name: `google_sql_database_instance.main`) without applying all 15 changes. Which Terraform command targets a specific resource?
⚠ Common exam trap
Google Cloud often tests the distinction between valid Terraform flags like `-target` and common but invalid flags such as `--resource`, `-only`, or `--filter`, exploiting candidates' familiarity with other tools (e.g., `kubectl` or `gcloud`) that use similar but different syntax.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
terraform apply -target=google_sql_database_instance.main
Terraform uses the `-target` flag to limit the operation to a specific resource address, allowing you to apply only the `google_sql_database_instance.main` resource without affecting the other 14 resources in the plan. This is the standard Terraform syntax for targeting a single resource during `apply` or `destroy` operations.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
terraform apply --resource=google_sql_database_instance.main
Why it's wrong here
The `-resource` flag is not part of the Terraform CLI. When you run `terraform apply --resource=google_sql_database_instance.main`, Terraform exits with an error because `apply` accepts `-target` for resource selection, not `--resource`. The correct syntax to limit apply scope is `-target=ADDRESS`, where ADDRESS uses the resource type and name in the configuration. No `--resource` flag exists in any Terraform version.
- ✓
terraform apply -target=google_sql_database_instance.main
Why this is correct
`-target=google_sql_database_instance.main` is the correct way to scope a Terraform apply to a single resource. The `-target` flag accepts a resource address in `TYPE.NAME` form (here `google_sql_database_instance.main`) and will apply that resource plus only the resources it directly or indirectly depends on. This creates the Cloud SQL instance without applying the other 14 unrelated resources in the plan. It is the standard targeted-apply pattern for isolating a specific infrastructure change.
- ✗
terraform apply -only=google_sql_database_instance.main
Why it's wrong here
The `-only` flag is unrecognized by `terraform apply`; Terraform's CLI has no `-only` option in any command. Even if you intended to apply only one resource, the supported mechanism is `-target=google_sql_database_instance.main`, which automatically includes any dependencies required by that resource. `-only` would produce an invalid flag error and perform zero changes.
- ✗
terraform plan --filter=google_sql_database_instance.main && terraform apply
Why it's wrong here
`terraform plan` does not support a `--filter` flag, so this command fails before any planning occurs. Assuming the plan succeeded, the subsequent `terraform apply` would operate on the full plan, which includes all 15 resources, because a plan command without `-target` covers the entire configuration. To limit the actual apply, you must pass `-target` directly to `terraform apply` (or `plan`) so that only the selected resource and its dependencies are included.
Go deeper
Related to this question
About these practice questions
Courseiva writes every ACE question from scratch — 769 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This ACE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the ACE exam.