nerdexam
HashiCorp

TA-002-P · Question #423

Which of the following is true about terraform apply? (Choose two.)

The correct answer is A. It only operates on infrastructure defined in the current working directory or workspace C. Depending on provider specification, Terraform may need to destroy and recreate your. terraform apply operates on infrastructure defined in the current working directory's configuration and workspace, and can sometimes destroy and recreate resources based on provider logic.

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

Question

Which of the following is true about terraform apply? (Choose two.)

Options

  • AIt only operates on infrastructure defined in the current working directory or workspace
  • BYou must pass the output of a terraform plan command to it
  • CDepending on provider specification, Terraform may need to destroy and recreate your
  • DBy default, it does not refresh your state file to reflect current infrastructure configuration
  • EYou cannot target specific resources for the operation

How the community answered

(27 responses)
  • A
    96% (26)
  • E
    4% (1)

Why each option

terraform apply operates on infrastructure defined in the current working directory's configuration and workspace, and can sometimes destroy and recreate resources based on provider logic.

AIt only operates on infrastructure defined in the current working directory or workspaceCorrect

terraform apply executes the actions defined by the configuration files in the current working directory or selected workspace, making it specific to that context.

BYou must pass the output of a terraform plan command to it

While you can pass a plan file to terraform apply, it is not a requirement; terraform apply can generate a plan itself if no plan file is provided.

CDepending on provider specification, Terraform may need to destroy and recreate yourCorrect

If a resource's attribute is changed to one that cannot be updated in-place by the provider, Terraform may need to destroy the existing resource and recreate it with the new configuration.

DBy default, it does not refresh your state file to reflect current infrastructure configuration

By default, terraform apply performs an implicit refresh to update the state file with the latest real-world infrastructure configuration before proposing changes.

EYou cannot target specific resources for the operation

terraform apply supports targeting specific resources using the -target option, allowing selective application of changes.

Concept tested: Terraform apply command behavior

Source: https://developer.hashicorp.com/terraform/cli/commands/apply

Topics

#terraform apply#resource lifecycle#configuration scope

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice