Chapter 7 of 8 · HashiCorp Terraform Associate 004

Maintain Infrastructure with Terraform

Import blocks, terraform import, inspecting state and verbose logging with TF_LOG.

  • 2topics
  • 9 minfast track
  • 1diagrams and exhibits

Topics in this chapter

Take them in order, or jump to the one you need.

  1. 1Importing Existing InfrastructureTerraform Associate 004: import existing resources with import blocks, generate configuration with -generate-config-out, or use…Diagram5 min
  2. 2Inspecting State and Verbose LoggingTerraform Associate 004: inspect state with terraform state list, state show, show and output, and enable verbose logs with…4 min

About this chapter

What this chapter covers

Maintain infrastructure with Terraform covers the work after the first apply. You bring existing resources under Terraform management, look inside state to see what Terraform knows, and switch on detailed logs when something goes wrong.

The chapter has two parts: importing existing infrastructure with import blocks or the terraform import command, then inspecting state from the CLI and using verbose logging with the TF_LOG environment variables.

Questions are single-answer, multiple-answer ("Pick the 2 correct responses below") and true or false statements, mostly direct recall of commands and behavior plus short HCL snippets that open "Consider the following configuration snippet:". There are no exhibits.

How the topics fit together

Existing resourceimport blockManaged by TerraformInspect statestate list, state showProblemTF_LOGDetailed logs

Import puts resources that already exist into state. The inspection commands show what state now holds, and verbose logging explains what Terraform and its providers did when the output alone is not enough.

  • Import questions ask which block or command adds an existing resource to state and whether configuration is written for you.
  • Inspection questions ask which command lists resources, shows one resource's attributes or prints outputs.
  • Logging questions ask which environment variable turns logs on, which levels exist and how to write logs to a file.
Exam tip

Match the verb to the command. "List" is terraform state list, "attributes of one resource" is terraform state show, "the whole state or a saved plan" is terraform show, and "values the configuration exports" is terraform output.

How to use these pages

Each topic page has the same shape, so you can skim for what you need.

  • What it is: the idea in plain words.
  • How it works: the mechanism, with tables and examples.
  • What to remember for the exam: the facts to memorize and how questions are phrased.
  • Common mistakes: the classic traps.
  • Check yourself: three questions to test your understanding.

Ready for more practice?

The full HashiCorp Terraform Associate 004 question bank has 600 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by HashiCorp. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.