Free Terraform Associate 004 Exam Braindumps
Terraform Associate 004 Questions 121–125 (page: 26)

Updated On: 10-Feb-2026

You should run terraform fnt to rewrite all Terraform configurations within the current working directory to conform to Terraform-style conventions.

  1. True
  2. False

Answer(s): A

Explanation:

You should run terraform fmt to rewrite all Terraform configurations within the current working directory to conform to Terraform-style conventions. This command applies a subset of the Terraform language style conventions, along with other minor adjustments for readability. It is recommended to use this command to ensure consistency of style across different Terraform codebases. The command is optional, opinionated, and has no customization options, but it can help you and your team understand the code more quickly and easily. Reference = : Command: fmt : Using Terraform fmt Command to Format Your Terraform Code



Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.

  1. True
  2. False

Answer(s): B

Explanation:

Terraform can manage resource dependencies implicitly or explicitly. Implicit dependencies are created when a resource references another resource or data source in its arguments. Terraform can infer the dependency from the reference and create or destroy the resources in the correct order. Explicit dependencies are created when you use the depends_on argument to specify that a resource depends on another resource or module. This is useful when Terraform cannot infer the dependency from the configuration or when you need to create a dependency for some reason outside of Terraform's scope. Reference = : Create resource dependencies : Terraform Resource Dependencies

Explained



Which provider authentication method prevents credentials from being stored in the state file?

  1. Using environment variables
  2. Specifying the login credentials in the provider block
  3. Setting credentials as Terraform variables
  4. None of the above

Answer(s): D

Explanation:

None of the above methods prevent credentials from being stored in the state file. Terraform stores the provider configuration in the state file, which may include sensitive information such as credentials. This is a potential security risk and should be avoided if possible. To prevent credentials from being stored in the state file, you can use one of the following methods:

Use environment variables to pass credentials to the provider. This way, the credentials are not part of the provider configuration and are not stored in the state file. However, this method may not work for some providers that require credentials to be set in the provider block.

Use dynamic credentials to authenticate with your cloud provider. This way, Terraform Cloud or Enterprise will request temporary credentials from your cloud provider for each run and use them to provision your resources. The credentials are not stored in the state file and are revoked after the run is completed. This method is supported for AWS, Google Cloud Platform, Azure, and Vault. Reference = : [Sensitive Values in State] : Authenticate providers with dynamic credentials



In Terraform HCL, an object type of object({name=string, age-number}) would match this value.

  1. Option A
  2. Option B
  3. Option C
  4. Option D

Answer(s): B

Explanation:

From the official Terraform Type Constraints Documentation:

The object({ name = string, age = number }) type expects:

name to be aquoted string, e.g. "John"

age to be anumber, e.g. 52

Option Bsatisfies both:

{

name = "John" #Valid string age = 52 #Valid number

}

Let's analyze the incorrect ones:

Option A: "fifty two" is not a valid number.

Option C: John is unquoted (invalid string), and "fifty two" is not a number.

Option D: name = John is not quoted, making it an invalid string in HCL.

Terraform is strict about type and formatting. Stringsmust be quoted, and numbersmust be numeric literals.



Which Terraform collection type should you use to store key/value pairs?

  1. Set
  2. Map
  3. Tuple
  4. list

Answer(s): B

Explanation:

The Terraform collection type that should be used to store key/value pairs is map. A map is a collection of values that are accessed by arbitrary labels, called keys. The keys and values can be of any type, but the keys must be unique within a map. For example, var = { key1 = "value1", key2 = "value2" } is a map with two key/value pairs. Maps are useful for grouping related values together, such as configuration options or metadata. Reference = [Collection Types], [Map Type Constraints]



Viewing page 26 of 53
Viewing questions 126 - 130 out of 147 questions


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

AI Tutor AI Tutor 👋 I’m here to help!