What command is used to remove a resource from the Terraform state?

Prepare for your Terraform Associate Exam with our engaging quiz. Test your knowledge with multiple choice questions and receive detailed explanations to enhance your understanding. Ace your exam with confidence!

The command used to remove a resource from the Terraform state is "terraform taint." When you mark a resource as tainted, it tells Terraform that the resource needs to be destroyed and recreated during the next apply operation. This indicates to Terraform that the current state of the resource is not in sync with the desired state defined in your configuration.

The "terraform taint" command doesn't directly remove the resource from the state file but rather marks it for destruction. When you subsequently run "terraform apply," Terraform will recognize the tainted resource and recreate it based on the current configuration and desired state. This is particularly useful when you want to ensure that a resource is replaced due to configuration changes or issues with the existing resource.

In contrast, other commands listed do not serve this purpose: some do not exist in Terraform's command set, while others do not interact with the state file in the way that "taint" does.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy