nerdexam
HashiCorp

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.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

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)
  • A
    3% (1)
  • C
    94% (29)
  • E
    3% (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.

AThe execution plan

The execution plan is generated by terraform plan and consumed by terraform apply; it is not changed by apply itself.

BTerraform code

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.

CCloud infrastructureCorrect

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.

DState fileCorrect

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.

EThe .terraform directory

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

#terraform apply#state file#cloud infrastructure#execution plan

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice