Skip to main content

TERRAFORM-ASSOCIATE-004 Real Exam Questions

HashiCorp Certified: Terraform Associate (004)

396 questions available · Page 1 of 40

Updated Exam DumpsVerified AnswersPass Guarantee

Get Complete Exam Dumps
Question 1 Single choice

How does Terraform manage most dependencies between resources?

  1. A

    Terraform will automatically manage most resource dependencies

  2. B

    Using the depends_on parameter

  3. C

    By defining dependencies as modules and including them in a particular order

  4. D

    The order that resources appear in Terraform configuration indicates dependencies

Show answer and explanation

Correct answer: A

Explanation

Terraform infers most dependencies by analyzing references between resource expressions and then orders operations through its dependency graph. This automatic management handles relationships visible in configuration without depending on file order. depends_on is reserved for additional relationships that Terraform cannot infer from expression references.

Question 2 Single choice

As a developer, you want to ensure your plugins are up to date with the latest versions.

Which Terraform command should you use?

  1. A

    terraform refresh -upgrade

  2. B

    terraform apply -upgrade

  3. C

    terraform init -upgrade

  4. D

    terraform providers -upgrade

Show answer and explanation

Correct answer: C

Explanation

terraform init is responsible for installing and selecting provider plugins for a working directory. Adding -upgrade tells initialization to consider newer acceptable versions instead of retaining previously selected versions when the configured constraints allow an upgrade. The refresh, apply, and providers commands shown do not use -upgrade for this plugin update task.

Question 3 Single choice

Before you can use a remote backend, you must first execute terra-form init.

  1. A

    True

  2. B

    False

Show answer and explanation

Correct answer: A

Explanation

The working directory must be initialized after a backend is configured or changed. terraform init prepares that backend, verifies access to it, and handles state initialization or migration as needed. Until initialization completes, later Terraform operations cannot use the newly configured remote backend correctly.

Question 4 Single choice

Which sequence best supports review before infrastructure changes are executed?

  1. A

    Apply, initialize, validate, plan, then review

  2. B

    Initialize, validate, plan, review, then apply

  3. C

    Validate, apply, initialize, review, then plan

  4. D

    Plan, apply, initialize, validate, then review

Show answer and explanation

Correct answer: B

Explanation

Initialization prepares the working directory and required dependencies. Validation then checks the configuration, and planning calculates proposed infrastructure actions. Placing review after the plan allows those actions to be examined before apply executes them, which is the sequence required for meaningful pre-change approval.

Question 5 Single choice

You are using a networking module in your Terraform configuration with the name label my-network. In your main configuration you have the following code:

When you run terraform validate, you get the following error:

What must you do to successfully retrieve this value from your networking module?

  1. A

    Change the reference value to my-network,outputs,vmet_id

  2. B

    Define the attribute vmet_id as a variable in the networking modeule

  3. C

    Define the attribute vnet_id as an output in the networking module

  4. D

    Change the reference value module.my,network,outputs,vnet_id

Show answer and explanation

Correct answer: C

Explanation

A parent configuration can retrieve only values that a child module explicitly exports. The networking module must define vnet_id as an output whose value references the relevant internal attribute. Once exported, the caller can access it through the module reference. Declaring it as an input variable would send a value into the module, which is the opposite direction.

Question 6 Single choice

Module variable assignments are inherited from the parent module and you do not need to explicitly set them.

  1. A

    True

  2. B

    False

Show answer and explanation

Correct answer: B

Explanation

Each child module has its own input-variable interface and scope. A parent module passes values through arguments in the child module block; those assignments are not inherited automatically merely because similarly named values exist in the parent. If an input is not explicitly passed, the child must have an applicable default or the input remains required.

Question 7 Single choice

HashiCorp Configuration Language (HCL) supports user-denned functions.

  1. A

    True

  2. B

    False

Show answer and explanation

Correct answer: B

Explanation

HCL configurations can call the functions Terraform provides, but HCL does not provide a facility for declaring arbitrary user-defined functions. Repeated expressions can be organized with local values or modules, yet those constructs do not create new callable functions. The statement is therefore false.

Question 8 Single choice

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

  1. A

    Using environment variables

  2. B

    Specifying the login credentials in the provider block

  3. C

    Setting credentials as Terraform variables

  4. D

    None of the above

Show answer and explanation

Correct answer: A

Explanation

Environment variables let the provider obtain credentials from the process environment at runtime instead of placing secret values in Terraform configuration or passing them through Terraform-managed input values. Because the credentials are supplied outside the configuration data being evaluated, this method avoids recording them as state data.

Question 9 Multiple choice

Which two core Terraform workflow steps are used to preview proposed changes and then provision new infrastructure? Choose two correct answers.

  1. A

    Plan

  2. B

    Import

  3. C

    Alidate

  4. D

    Init

  5. E

    apply

Show answer and explanation

Correct answers: A, E

Explanation

terraform plan calculates and presents the actions required to move from the current state to the declared configuration. terraform apply then executes those actions to provision the resources. Initialization prepares the working directory, while import adopts existing infrastructure rather than provisioning new infrastructure.

Question 10 Multiple choice

Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.

  1. A

    Automated infrastructure deployment visualization.

  2. B

    A web-based user interface (UI).

  3. C

    Automatic backups of configuration and state.

  4. D

    Remote state storage.

Show answer and explanation

Correct answers: B, D

Explanation

HCP Terraform and Terraform Cloud provide a web-based user interface for viewing and managing workspace activity without relying solely on local CLI interaction. They also keep workspace state remotely, giving runs a shared state location outside an individual operator's machine. These are two distinct platform capabilities.