What happens if you modify a resource and run terraform apply?

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!

When you modify a resource and run the terraform apply command, Terraform evaluates the current state of the resource against the desired state defined in your configuration files. If there are differences between the existing resource's configuration and what is specified in the Terraform configuration, Terraform will typically update the resource in place to match the desired state.

This in-place update is efficient because it allows for minimal disruption to existing resources, making modifications without needing to destroy and recreate the resource, as long as the underlying provider supports such operations. For instance, if you change a property of an AWS EC2 instance (like an instance type), Terraform will send an update request to AWS, and AWS will adjust the instance accordingly without recreating it from scratch.

In some cases, if a change cannot be applied in place due to provider limitations, Terraform may choose to recreate the resource. However, the general behavior is to perform an in-place update whenever possible. Therefore, the correct answer highlights the most common action taken by Terraform during an apply when resource modifications are detected.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy