hardMultiple ChoiceObjective-mapped
Google ACE Practice Question: A team is using Terraform to manage…
A team is using Terraform to manage infrastructure in Google Cloud. After running terraform apply, they receive an error: 'Error 409: Resource already exists'. The team needs to resolve this without deleting and recreating the resource. What should they do?
⚠ Common exam trap
Google Cloud often tests the misconception that 'terraform refresh' can fix state mismatches for missing resources, but it only syncs attributes for resources already in state, not imports new ones.
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
✓
Import the existing resource into Terraform state with 'terraform import'.
The 'Error 409: Resource already exists' indicates that the resource was created outside of Terraform or the state file lost track of it. Running 'terraform import' brings the existing resource under Terraform management by adding its current attributes to the state file, allowing subsequent operations without deletion or recreation.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Run 'terraform refresh' to update the state file.
Why it's wrong here
Running terraform refresh only reconciles existing state records with current GCP infrastructure attributes; it has no mechanism to discover or add resources that were created outside Terraform. Since the pre-existing resource is absent from the state file, refresh will leave it untouched and unmanaged, so the next plan would still attempt to create a duplicate. This command is therefore insufficient for adopting the existing resource.
- ✓
Import the existing resource into Terraform state with 'terraform import'.
Why this is correct
terraform import explicitly binds an existing GCP resource to a specified resource address in Terraform state, using the syntax terraform import <address> <resource_id>. After import, Terraform considers the resource as managed, but you must still write matching configuration; otherwise a subsequent plan will show changes. This is the only direct way to bring an out-of-band resource under Terraform management.
- ✗
Set the 'create_before_destroy' lifecycle rule on the resource.
Why it's wrong here
The create_before_destroy lifecycle rule only controls whether Terraform creates a replacement before destroying the old resource during an update or replacement. It cannot add an unmanaged resource to the state, and it has no effect on resources that were never tracked. The pre-existing resource would remain ignored by Terraform regardless of this lifecycle setting.
- ✗
Change the resource name in the Terraform configuration.
Why it's wrong here
Changing the resource name in configuration produces a brand new resource address, causing Terraform to plan a fresh resource while leaving the existing one untouched and unmanaged. It does not associate the old infrastructure with the new address, so the original resource would still be orphaned. This action would likely result in duplication (creating a second instance) rather than adoption.
Visual reference
Go deeper
Related to this question
About these practice questions
This ACE question is part of Courseiva's 769-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.