Terraform Associate · Domain 8 of 8 · 10% of the exam

Terraform Associate Domain 8: HCP Terraform

20 free practice questions for HCP Terraform in the HashiCorp Certified: Terraform Associate (004) exam. Try each question first, then open "Show answer" for the correct option and explanation.

HCP Terraform practice questions

  1. Question 1. What is HCP Terraform?

    1. A language server that adds Terraform support to editors
    2. HashiCorp's managed service for running Terraform with shared state and collaboration
    3. A public registry that only hosts provider plugins
    4. A CLI command that formats and validates configuration
    Show answer

    Answer: B. HashiCorp's managed service for running Terraform with shared state and collaboration

    HCP Terraform, formerly Terraform Cloud, stores state, runs plans and applies, and adds access control, policies, and a private registry.

  2. Question 2. Which block connects a configuration to HCP Terraform?

    1. A cloud block inside the terraform block
    2. A provider "hcp" block
    3. A remote_state data source
    4. A module block with source = "hcp"
    Show answer

    Answer: A. A cloud block inside the terraform block

    The cloud block sets the organization and the workspace (by name or by tags). Run terraform init after adding it.

  3. Question 3. Which command gets an API token so the CLI can use HCP Terraform?

    1. terraform auth
    2. terraform connect
    3. terraform init -token
    4. terraform login
    Show answer

    Answer: D. terraform login

    It opens a browser to create a token and saves it in the CLI credentials file.

  4. Question 4. What does an HCP Terraform workspace hold?

    1. Only the provider binaries that its runs download
    2. The state of several unrelated configurations together
    3. A configuration's state, variables, permissions, and run history
    4. Only the modules published to the private registry
    Show answer

    Answer: C. A configuration's state, variables, permissions, and run history

    HCP Terraform workspaces are more than CLI workspaces: each is a unit of access control and run history.

  5. Question 5. What are projects in HCP Terraform for?

    1. Grouping related workspaces and granting teams access to them
    2. Storing provider plugins for the whole organization
    3. Replacing organizations as the top level of the account
    4. Running Terraform locally instead of on remote workers
    Show answer

    Answer: A. Grouping related workspaces and granting teams access to them

    Projects make permissions and variable sets easier to manage as the number of workspaces grows.

  6. Question 6. In the VCS-driven workflow, what starts runs?

    1. A cron schedule only
    2. Commits and pull requests in the connected repository
    3. A user running terraform apply locally
    4. Changes in the cloud console
    Show answer

    Answer: B. Commits and pull requests in the connected repository

    Pushes to the tracked branch queue runs; pull requests get speculative plans.

  7. Question 7. In the CLI-driven workflow with HCP Terraform, what happens when you run terraform plan locally?

    1. The plan runs only on your laptop, using local state
    2. The plan is saved to a local file for you to upload
    3. Nothing happens, because plans must be started in the UI
    4. The plan runs remotely and streams its output to your terminal
    Show answer

    Answer: D. The plan runs remotely and streams its output to your terminal

    Your local files are uploaded, the run executes in HCP Terraform, and its output is streamed back.

  8. Question 8. Which workflow lets an external tool, such as a custom pipeline, upload configuration and start runs?

    1. The VCS-driven workflow
    2. The local backend workflow
    3. The API-driven workflow
    4. The workspace-only workflow
    Show answer

    Answer: C. The API-driven workflow

    It gives full control over when runs happen and what's uploaded, at the cost of more integration work.

  9. Question 9. What is a speculative plan in HCP Terraform?

    1. A plan-only run, for example on a pull request, that can't be applied
    2. A plan that runs on a fixed schedule to check for changes
    3. A plan that is applied automatically once it finishes
    4. A plan that runs against a workspace in another organization
    Show answer

    Answer: A. A plan-only run, for example on a pull request, that can't be applied

    It shows reviewers the effect of a change before it's merged.

  10. Question 10. What is a variable set?

    1. A tfvars file stored in the connected Git repository
    2. A group of variables shared across several workspaces or projects
    3. The local values defined inside a single workspace
    4. The list of providers that a workspace requires
    Show answer

    Answer: B. A group of variables shared across several workspaces or projects

    For example, cloud credentials applied to every workspace in a project.

  11. Question 11. A variable in HCP Terraform is marked sensitive. What happens to it?

    1. It's visible to all organization members
    2. It's printed in run logs
    3. It's stored in the configuration repository
    4. It becomes write-only and can't be read back in the UI or API
    Show answer

    Answer: D. It becomes write-only and can't be read back in the UI or API

    Terraform runs still receive the value, but people can only replace it, not view it.

  12. Question 12. Where do Sentinel or OPA policies run in an HCP Terraform run?

    1. Before init
    2. After the plan and before the apply
    3. Only after the apply
    4. In the provider plugin
    Show answer

    Answer: B. After the plan and before the apply

    Policies check the plan, for example to block untagged resources or oversized instances, before anything changes.

  13. Question 13. What are run tasks in HCP Terraform?

    1. Scheduled jobs that destroy workspaces at night
    2. Variables passed from one run to the next
    3. Integrations that call external services, such as scanners, during a run
    4. The individual steps of the local CLI workflow
    Show answer

    Answer: C. Integrations that call external services, such as scanners, during a run

    Run tasks can pass or fail a run based on the external service's result.

  14. Question 14. By default, where do HCP Terraform runs execute?

    1. On HCP Terraform's managed workers
    2. On the user's laptop
    3. On a VM in each cloud account
    4. Inside the backend bucket
    Show answer

    Answer: A. On HCP Terraform's managed workers

    Local execution mode can be selected per workspace, keeping only state in HCP Terraform.

  15. Question 15. Your resources are only reachable from a private network. How can HCP Terraform manage them?

    1. It can't manage private resources
    2. By opening the network to the internet
    3. By using the local backend
    4. By running HCP Terraform agents inside that network
    Show answer

    Answer: D. By running HCP Terraform agents inside that network

    Agents poll HCP Terraform for work and run Terraform from within your network.

  16. Question 16. What does HCP Terraform's health assessment feature, drift detection, do?

    1. Applies configuration changes automatically on a schedule
    2. Checks regularly whether real infrastructure has drifted from state
    3. Replaces outdated provider versions in the lock file
    4. Formats Terraform code in incoming pull requests
    Show answer

    Answer: B. Checks regularly whether real infrastructure has drifted from state

    It alerts you to drift without anyone running a plan. Continuous validation also re-runs check blocks.

  17. Question 17. How are permissions to workspaces granted in HCP Terraform?

    1. Through branch protection rules in the Git repository
    2. By sharing one organization API token with users
    3. To teams, at organization, project, or workspace level
    4. Through arguments set in each provider configuration
    Show answer

    Answer: C. To teams, at organization, project, or workspace level

    Users join teams, and teams get roles such as read, plan, write, or admin on projects and workspaces.

  18. Question 18. What does a run trigger do?

    1. Queues a run in one workspace when another workspace applies successfully
    2. Runs plans in a workspace on a fixed schedule
    3. Triggers an upgrade of every provider in the lock file
    4. Sends an email notification after every plan
    Show answer

    Answer: A. Queues a run in one workspace when another workspace applies successfully

    It's useful when one workspace consumes another's outputs, such as an app depending on a network workspace.

  19. Question 19. Which HCP Terraform feature shows a cost estimate for supported resources during a run?

    1. Run tasks
    2. Variable sets
    3. The private registry
    4. Cost estimation
    Show answer

    Answer: D. Cost estimation

    It runs after the plan, and policies can use its results, for example to block expensive changes.

  20. Question 20. The cloud block selects workspaces with tags instead of a single name. How do you choose which workspace a command uses?

    1. Set TF_LOG to the workspace name
    2. Use terraform workspace select
    3. Edit the state file
    4. Rerun terraform login
    Show answer

    Answer: B. Use terraform workspace select

    With tags, several workspaces match, so you pick one with terraform workspace select or the TF_WORKSPACE variable.

HashiCorp, Terraform, and HCP Terraform are trademarks of HashiCorp, Inc. These questions are original study material, not questions from the real exam.