TERRAFORM-ASSOCIATE-003 practice question 20 of 30
[Understand Terraform Basics and CLI] You have a simple Terraform configuration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created successfully. What will happen if you terraform apply again immediately afterward without changing any Terraform code?
Full set: 226 questionsTerraform is idempotent, meaning that applying the same configuration multiple times will result in the same infrastructure state. After the first successful terraform apply, Terraform records the created VM and its attributes in a state file. When you run terraform apply again without any changes to the configuration, Terraform compares the desired state (your code) with the current state (recorded in the state file and verified against the cloud provider). Since they are identical, Terraform determines that no changes are needed and will take no action on the infrastructure, simply reporting that it is already up-to-date.
A. Terraform only terminates and recreates resources if a configuration change requires it (e.g., changing an immutable property) or if the resource is tainted.
B. The state file tracks managed resources, preventing Terraform from creating duplicates for the same resource block in the configuration.
C. The VM's state was already recorded in the state file during the first successful apply command.
1. HashiCorp Terraform Documentation
"Core Terraform Workflow": The "Apply" section describes this behavior: "If the plan is acceptable
Terraform will proceed with the actions in the correct order... If you run terraform apply again
Terraform will look at your infrastructure and see that nothing has changed
so it won't do anything."
Source: HashiCorp
"Core Terraform Workflow"
https://developer.hashicorp.com/terraform/language/core-workflow. Accessed under the "Apply" section.
2. HashiCorp Terraform Documentation
"Command: apply": "If you run terraform apply with no pending changes
Terraform will inform you that no changes are needed and exit immediately."
Source: HashiCorp
"Command: apply"
https://developer.hashicorp.com/terraform/cli/commands/apply. Accessed under the "Usage" and main description sections.
3. HashiCorp Terraform Documentation
"Purpose of Terraform State": "This state is used by Terraform to map real world resources to your configuration
keep track of metadata
and to improve performance for large infrastructures... This allows Terraform to detect drift and determine which changes to make."
Source: HashiCorp
"Purpose of Terraform State"
https://developer.hashicorp.com/terraform/language/state. Accessed under the introductory paragraphs.
Keep practicing
Take the free TERRAFORM-ASSOCIATE-003 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other TERRAFORM-ASSOCIATE-003 practice questions
- Question 1[Understand Terraform Basics and CLI] If you update the version constraint in your Terraf…
- Question 2[Navigate Terraform State and Backends] Terraform variable names are saved in the state f…
- Question 3[Understand Terraform Basics and CLI] You modified your Terraform configuration and run T…
- Question 4[Understand Terraform Basics and CLI] You must use different Terraform commands depending…
- Question 6[Understand Terraform Basics and CLI] terraform init creates an example main.tf file in t…
- Question 7[Understand Terraform Basics and CLI] terraform validate confirms that your infrastructur…
