Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Terraform Associate topic 1 question 48 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 48
Topic #: 1
[All Terraform Associate Questions]

You have never used Terraform before and would like to test it out using a shared team account for a cloud provider. The shared team account already contains
15 virtual machines (VM). You develop a Terraform configuration containing one VM, perform terraform apply, and see that your VM was created successfully.
What should you do to delete the newly-created VM with Terraform?

  • A. The Terraform state file contains all 16 VMs in the team account. Execute terraform destroy and select the newly-created VM.
  • B. The Terraform state file only contains the one new VM. Execute terraform destroy.
  • C. Delete the Terraform state file and execute Terraform apply.
  • D. Delete the VM using the cloud provider console and terraform apply to apply the changes to the Terraform state file.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
habros
Highly Voted 1 year, 10 months ago
B. Only resources mentioned in terraform will be applied and reflected in state. Resources manually created in console and/or not defined in code will not be captured by Terraform
upvoted 24 times
...
wangchung
Highly Voted 1 year, 11 months ago
The question says " You develop a Terraform configuration containing one VM,"... would that not mean that a different state file therefore the 15 vms would not be registered
upvoted 5 times
wangchung
1 year, 11 months ago
B still. " A. The Terraform state file contains all 16 VMs in the team account. Execute terraform destroy and select the newly-created VM. " ---- what does that meant "select the newly-created VM" you can't destroy a single resource, to destroy and recreate a new resource you use terraform taint to mark the resource for deletions and recreation
upvoted 4 times
Jaro3000
1 year, 10 months ago
You can destroy a single resource using --target But still B as we assume we have a separate state file with our vm only
upvoted 2 times
...
...
...
vibzr2023
Most Recent 3 weeks, 2 days ago
B. The Terraform state file only contains the one new VM. Execute terraform destroy: This is the correct approach. When you create resources with Terraform, it tracks those resources in a state file. Since you've only created one VM with Terraform, only that VM is tracked in the state file. Running terraform destroy will remove all resources tracked in the state file, which in this case, is just the one VM you've created.
upvoted 1 times
vibzr2023
3 weeks, 2 days ago
A. The Terraform state file contains all 16 VMs in the team account. Execute terraform destroy and select the newly-created VM: This option is incorrect because Terraform's state file does not automatically track resources that were not created or imported through Terraform. Since the 15 other VMs in the account were not managed by this Terraform configuration, they will not be in the state file, and terraform destroy will not affect them. C. Delete the Terraform state file and execute Terraform apply: This approach is not recommended. Deleting the state file removes Terraform's knowledge of the resources it manages, but does not actually delete those resources from the cloud provider. Running terraform apply afterwards would attempt to create the resources anew based on the
upvoted 1 times
vibzr2023
3 weeks, 2 days ago
D. Delete the VM using the cloud provider console and terraform apply to apply the changes: This option is not advisable because it involves manually deleting a resource outside of Terraform, which can lead to discrepancies between your real infrastructure and Terraform's state. If a resource is manually deleted, Terraform's state file still thinks the resource exists, and running terraform apply would likely result in Terraform trying to "reconcile" the state by re-creating the deleted VM, which is not the intended outcome.
upvoted 1 times
...
...
...
gofavad926
6 months, 3 weeks ago
Selected Answer: B
B, destroy the created instance
upvoted 1 times
...
Ni33
11 months, 2 weeks ago
Selected Answer: B
B is the correct answer. Terraform only maintains desired state and not actual state of the infrastructure in the account.
upvoted 2 times
...
Power123
1 year ago
B is the answer
upvoted 1 times
...
oab720
1 year, 3 months ago
Selected Answer: B
Don’t worry, you won’t delete prod instances
upvoted 3 times
...
FarziWaliMarzi
1 year, 3 months ago
mostly hypothetically assumed answers, not solid concrete answer here? I somehow feel that its a very poorly framed question.
upvoted 1 times
...
Network_1
1 year, 4 months ago
You created a Terraform configuration containing 1 VM... You didn't modify the existing Terraform configuration. Hence, only the config you created would be deleted
upvoted 1 times
...
pmzone
1 year, 6 months ago
The single Vm can be deleted using -target option in terraform destroy. In this case, I am assuming that the 15 VM's are created using TF.
upvoted 1 times
...
therealquan
1 year, 8 months ago
Selected Answer: B
Definitely B
upvoted 3 times
therealquan
1 year, 8 months ago
the other existing VMs need to be imported to be affected by the terraform destroy
upvoted 3 times
...
...
yuvifose
1 year, 9 months ago
Selected Answer: B
Since the other machines are not in Terraform yet, it won't touch them
upvoted 2 times
...
Ahmad_Terraform
1 year, 9 months ago
because its shared ac So A is correct
upvoted 1 times
...
Eltooth
1 year, 9 months ago
Selected Answer: B
B is correct answer.
upvoted 2 times
...
VANSI
1 year, 9 months ago
Selected Answer: B
B easy
upvoted 4 times
...
Empel
1 year, 9 months ago
Selected Answer: B
Is B for sure. the state file does not contain information about anything else that you might have on the cloud provider
upvoted 2 times
...
Zam88
1 year, 10 months ago
You develop a Terraform configuration containing one VM, perform terraform apply, and see that your VM was created successfully. read the question carefully "Terraform configuration containing one VM, perform terraform apply" so only one VM is in state file. B should be correct
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...