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

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 207 discussion

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

While deploying a virtual machine, the first launch user_data script fails due to race condition with another resource deployed during the same Terraform run.

What is the least disruptive method to correct the issue?

  • A. Run terraform taint against the virtual machine’s resource name, then terraform apply
  • B. Restart the virtual machine from the cloud portal
  • C. Run terraform apply again
  • D. Run terraform destroy then terraform apply
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
zaaath
Highly Voted 1 year, 7 months ago
I'd go with A. If a user_data script fails during the creation of an EC2 instance, Terraform will not mark the resource as tainted automatically. This is because Terraform does not have visibility into the success or failure of the user_data script, as it is executed within the instance itself, and not directly controlled by Terraform. However, if the user_data script failure causes the instance to become unresponsive or otherwise unusable, Terraform may detect this during a subsequent plan or apply operation and mark the instance as "tainted". A tainted resource is one that Terraform cannot verify the current state of, and must be recreated in order to bring it back to a known state.
upvoted 9 times
...
Mantis
Highly Voted 1 year, 6 months ago
Selected Answer: A
The script deployment will not have been tracked within Terraform - and will therefore not re-run on the next 'apply' command. The resource the script is running on will have to be redeployed to trigger the script to run a second time - the least disruptive way do achieve this is with the 'taint' command
upvoted 5 times
...
lavendran93
Most Recent 2 months, 1 week ago
Selected Answer: C
A. Run terraform taint: This would force the virtual machine to be destroyed and recreated, which is more disruptive than reapplying. I think B
upvoted 1 times
...
alex78
9 months, 4 weeks ago
Selected Answer: C
If a creation-time provisioner fails, the resource is marked as tainted. A tainted resource will be planned for destruction and recreation upon the next terraform apply. https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax
upvoted 2 times
F_M
2 months, 3 weeks ago
We're not talking about provisioners but user_data a.k.a. cloud init.
upvoted 1 times
...
...
March2023
1 year, 5 months ago
Selected Answer: A
going with A
upvoted 1 times
...
Ni33
1 year, 6 months ago
A is correct
upvoted 2 times
...
Oleg_gol
1 year, 6 months ago
Selected Answer: C
C. Run terraform apply again
upvoted 2 times
...
Nunyabiznes
1 year, 7 months ago
Selected Answer: C
if it fails, you just re-run terraform apply again , why even run taint for something that didn't even got created in the first place. For example, you're trying to create Resource A, but it fails because resource B was being created. So what do you do to create resource A again ? - terraform apply
upvoted 3 times
...
camps
1 year, 7 months ago
Selected Answer: A
In this scenario, the user_data script failed due to a race condition with another resource being deployed simultaneously during the same Terraform run. The least disruptive method to correct the issue is to use the terraform taint command followed by terraform apply. Running terraform taint against the virtual machine's resource name marks the resource as tainted. Tainting a resource indicates that it has a problem and should be destroyed and recreated during the next terraform apply. By doing this, you force Terraform to recreate the virtual machine with the corrected user_data script, resolving the race condition without affecting other resources.
upvoted 2 times
...
Pietjeplukgeluk
1 year, 9 months ago
The question leaves room for interpretation. If a creation-time provisioner fails, the resource is marked as tainted. A tainted resource will be planned for destruction and recreation upon the next terraform apply. https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax
upvoted 1 times
David_C_90
1 year, 8 months ago
The question states user_data not provisioners...
upvoted 2 times
...
...
Abuu
1 year, 10 months ago
A is the Answer since the particular object has become degraded or damaged and Terraform taint will propose to replace it in the next plan you create.
upvoted 2 times
...
ArizonaClassics
1 year, 10 months ago
I will go for A
upvoted 2 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 ...