TA-002-P · Question #379
Which of the following does terraform apply change after you approve the execution plan? Choose two correct answers.
The correct answer is C. Cloud infrastructure D. State file. After approving the execution plan, terraform apply changes both the real-world cloud infrastructure and updates the local or remote Terraform state file.
Question
Which of the following does terraform apply change after you approve the execution plan? Choose two correct answers.
Options
- AThe execution plan
- BTerraform code
- CCloud infrastructure
- DState file
- EThe .terraform directory
How the community answered
(31 responses)- A3% (1)
- C94% (29)
- E3% (1)
Why each option
After approving the execution plan, `terraform apply` changes both the real-world cloud infrastructure and updates the local or remote Terraform state file.
The execution plan is generated by terraform plan and consumed by terraform apply; it is not changed by apply itself.
Terraform code (e.g., .tf files) defines the desired state and is written by the user; terraform apply reads it but does not modify it.
terraform apply is the command that provisions or modifies resources in the cloud infrastructure (e.g., AWS, Azure, GCP) based on the approved execution plan. It directly interacts with the cloud provider's APIs to create, update, or delete resources.
The Terraform state file (terraform.tfstate) is updated by terraform apply to record the real-world state of the infrastructure it manages, linking resources in the configuration to their actual counterparts in the cloud. This file is crucial for Terraform to understand what exists and how it relates to the configuration.
The .terraform directory contains provider plugins and modules, which are managed by terraform init and not directly altered by terraform apply.
Concept tested: Terraform apply command effects
Source: https://developer.hashicorp.com/terraform/cli/commands/apply
Topics
Community Discussion
No community discussion yet for this question.