Bitzu

Terraform Associate 004 ยท Core Terraform workflow

Plan options: target, replace, refresh-only, destroy

-target, -replace=ADDRESS (replacing taint), -refresh-only, -destroy, -var and -var-file on plan, when each is appropriate (3d).

Key points

  • target=ADDRESS limits the plan to the matching resource and its dependencies; it is meant for exceptional cases, not routine use. -replace=ADDRESS forces re-creation of one instance (the modern alternative to taint) and cannot be combined with -destroy. -refresh-only only updates state and outputs to match changes made outside Terraform. -destroy previews removing everything. -var and -var-file supply input variables.

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

Practice questions

Single choice

Which plan option forces one resource instance to be recreated?

  1. -replace=ADDRESS
  2. -refresh-only
  3. -var-file=FILE
  4. -detailed-exitcode
Show answer

Answer: A. -replace=ADDRESS

-replace=ADDRESS plans replacement of the given instance. The others record external changes, load variables, or alter the exit code.

Select all that apply

Which statements about -target are correct?

  1. It should be the default way to run every plan
  2. It limits planning to the resource instance and its dependencies
  3. It permanently excludes other resources from the configuration
  4. It tells Terraform to ignore the state file
  5. It is intended for exceptional cases such as recovering from mistakes
Show answer

Answer: B. It limits planning to the resource instance and its dependencies, E. It is intended for exceptional cases such as recovering from mistakes

-target narrows a run to the chosen resource and what it depends on, and is meant for exceptions. It excludes nothing permanently and does not bypass state.

True or false

-replace can be combined with -destroy in the same plan.

Show answer

Answer: False

False. -replace cannot be used with -destroy, since destroy mode already removes every object.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Terraform Associate 004 topics in this module