HashiCorp Terraform-Associate-004 Exam
HashiCorp Certified: Terraform Associate (004) (Page 5 )

Updated On: 7-Feb-2026

When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?

  1. You can import infrastructure without corresponding Terraform code
  2. Terraform will generate the corresponding configuration files for you
  3. Before you run terraform Import
  4. After you run terraform import

Answer(s): C

Explanation:

You need to write Terraform configuration files for the existing infrastructure that you want to import into Terraform, otherwise Terraform will not know how to manage it. The configuration files should match the type and name of the resources that you want to import.



Variables declared within a module are accessible outside of the module.

  1. True
  2. False

Answer(s): B

Explanation:

Variables declared within a module are only accessible within that module, unless they are explicitly exposed as output values1.



Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?

  1. Edit your state file to scrub out the sensitive data
  2. Always store your secrets in a secrets.tfvars file
  3. Delete the state file every time you run Terraform
  4. Store the state in an encrypted backend

Answer(s): D

Explanation:

This is a secure way to protect sensitive data in the state file, as it will be encrypted at rest and in transit2. The other options are not recommended, as they could lead to data loss, errors, or security breaches.



If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform Init.

  1. True
  2. False

Answer(s): A

Explanation:

If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform init3. This will ensure that you use the same provider versions across different machines and runs.



Once you configure a new Terraform backend with a terraform code block, which command(s) should you use to migrate the state file?

  1. terraform destroy, then terraform apply
  2. terraform init
  3. terraform push
  4. terraform apply

Answer(s): A

Explanation:

This command will initialize the new backend and prompt you to migrate the existing state file to the new location4. The other commands are not relevant for this task.



Viewing page 5 of 53
Viewing questions 21 - 25 out of 259 questions



Post your Comments and Discuss HashiCorp Terraform-Associate-004 exam prep with other Community members:

Join the Terraform-Associate-004 Discussion