HashiCorpAssociate levelPage 3 of 3

HashiCorp Terraform Associate (004) exam dumps: questions 201 to 223 of 223

Page 3 of the free HashiCorp Terraform Associate (004) question bank for the Terraform Associate 004 exam. Questions 201 to 223 are listed below, the first 5 in full with answers and explanations. Back to page 1 for the exam overview and FAQ.

Question bank last updated June 2026

Free HashiCorp Terraform Associate (004) practice questions

Questions 201 to 205 of 223

Pick an answer before you open the explanation. Each question also has its own page with a permalink.

HashiCorp Terraform Associate (004) Question 201

Single answer8 HCP Terraform

Your team has migrated a Terraform workflow from local execution to HCP Terraform. A workspace is configured to use the VCS-driven workflow, and the Terraform configuration includes an aws provider block that expects credentials from environment variables. The code plans successfully when engineers run it locally, but runs in HCP Terraform fail during provider authentication because no AWS credentials are available in the remote execution environment. You need to fix this without hardcoding secrets in the configuration or committing credential files to version control. What is the best solution?

  1. A

    Add the AWS access key and secret key as Terraform input variables in the workspace, then reference them directly in the provider block.

  2. B

    Store the AWS credentials as sensitive environment variables in the HCP Terraform workspace so remote runs can use them during plan and apply.

  3. C

    Commit a shared credentials file to the repository and configure the provider to read from that file during HCP Terraform runs.

  4. D

    Switch the workspace from remote execution to local execution so each engineer's local AWS CLI credentials are reused automatically.

Show answer and explanation

Correct answer: B

Explanation

In HCP Terraform, remote runs execute in an isolated environment, so local developer credentials are not automatically available. When a provider supports authentication through environment variables, the recommended approach is to set those values as workspace environment variables and mark secrets as sensitive. This keeps credentials out of Terraform configuration and out of version control while allowing remote plan and apply operations to authenticate successfully. Using Terraform input variables for cloud credentials is generally less appropriate than environment-based authentication for providers like AWS. Committing credential files is explicitly poor practice. See HashiCorp documentation for HCP Terraform workspace variables and provider authentication via environment variables.

  • A. Incorrect.

    This is not the best solution. Although Terraform variables can technically pass values into a provider block, cloud credentials are better handled as environment variables or a dynamic authentication mechanism rather than as Terraform input variables. Putting secrets into Terraform variables can increase exposure in configuration usage patterns and is not the recommended HCP Terraform approach for provider authentication when standard environment variables are supported.

  • B. Correct.

    This is correct. HCP Terraform supports workspace environment variables, including sensitive values, which are injected into the remote execution environment for plan and apply operations. For providers such as AWS, setting supported environment variables like AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY allows authentication without hardcoding credentials in code or storing them in version control.

  • C. Incorrect.

    This is incorrect and insecure. Committing credential files to version control exposes secrets and violates basic security practices. HCP Terraform is designed to avoid this by allowing sensitive environment variables and other secure credential injection methods instead of storing secrets in the repository.

  • D. Incorrect.

    This is incorrect because it avoids the problem rather than solving the remote execution requirement. In a VCS-driven HCP Terraform workflow, remote runs are a core feature, and switching back to local execution removes centralization, auditability, and consistency benefits. It also does not address how HCP Terraform itself should authenticate during remote runs.

HashiCorp Terraform Associate (004) Question 202

Single answer8 HCP Terraform

Your team uses HCP Terraform to manage AWS infrastructure across development and production workspaces. A security review finds that AWS access keys are hardcoded in Terraform variable values inside multiple workspaces. You need to redesign authentication so runs in HCP Terraform no longer rely on long-lived static AWS credentials, while still allowing each workspace to assume the correct AWS IAM role at run time. Which solution best meets this requirement?

  1. A

    Configure HCP Terraform dynamic provider credentials with AWS, establish the required trust relationship in AWS IAM, and map each workspace to the appropriate role so runs receive short-lived credentials automatically.

  2. B

    Store the AWS access key and secret key as sensitive Terraform variables in each workspace and mark them as write-only so users cannot read them after saving.

  3. C

    Commit the AWS credentials into a private module used by all workspaces, then reference that module from each root configuration to centralize secrets management.

  4. D

    Use local values in the Terraform configuration to construct the AWS credentials dynamically from workspace names so each workspace gets a different credential set.

Show answer and explanation

Correct answer: A

Explanation

The best answer is to use HCP Terraform dynamic provider credentials for AWS. This feature allows HCP Terraform runs to authenticate to AWS using short-lived credentials obtained through a trust relationship, rather than storing long-lived AWS access keys in workspace variables. In practice, teams configure AWS IAM to trust HCP Terraform's identity flow and then specify which role each workspace should assume. This is the recommended pattern for improving security, reducing secret sprawl, and supporting least-privilege access per workspace. Sensitive variables in HCP Terraform are useful when secrets must be stored, but they do not eliminate the risk of static credentials. HashiCorp documentation and best practices for HCP Terraform emphasize using dynamic credentials where supported, especially for cloud providers such as AWS.

  • A. Correct.

    Correct. HCP Terraform supports dynamic provider credentials for AWS so runs can obtain short-lived credentials instead of using static long-lived access keys. The typical setup involves configuring workload identity / trusted federation between HCP Terraform and AWS IAM, then assigning the appropriate IAM role per workspace or variable set. This aligns with security best practices by eliminating hardcoded secrets and limiting credential lifetime.

  • B. Incorrect.

    Incorrect. Marking variables as sensitive helps reduce exposure in the UI and logs, but the underlying approach still depends on long-lived static AWS credentials. The requirement specifically says runs should no longer rely on static credentials. Sensitivity settings improve handling of secrets; they do not replace static secrets with ephemeral credentials.

  • C. Incorrect.

    Incorrect. Storing credentials in a private module is not a valid secrets-management solution and is a serious security anti-pattern. Modules are for reusable infrastructure logic, not for embedding provider secrets. This would still use static credentials and would increase the blast radius if the module source were exposed.

  • D. Incorrect.

    Incorrect. Terraform local values are just expressions inside configuration and cannot securely generate valid AWS access keys and secret keys. AWS credentials must come from AWS identity mechanisms, such as IAM users, IAM roles, or federation. Constructing strings based on workspace names does not create authenticated AWS credentials.

HashiCorp Terraform Associate (004) Question 203

Single answer8 HCP Terraform

A platform team is migrating local Terraform workflows to HCP Terraform. They want every plan and apply to run remotely in HCP Terraform, use a shared and encrypted state backend, and allow developers to continue using the Terraform CLI from their laptops without manually pushing configuration through the UI. Which approach best meets these requirements with the least operational overhead?

  1. A

    Configure each workspace to use the local backend and ask developers to upload state files to HCP Terraform after each apply.

  2. B

    Add a cloud block to the Terraform configuration that targets the HCP Terraform organization and workspace, then run Terraform commands from the CLI using the remote workflow.

  3. C

    Store the state in an external S3 bucket and use HCP Terraform only as a dashboard for viewing run history.

  4. D

    Use Terraform Enterprise agents on every developer laptop so plans run locally but state is copied to HCP Terraform after completion.

Show answer and explanation

Correct answer: B

Explanation

The best answer is to use the CLI-driven remote workflow with HCP Terraform by defining a cloud block that points to the correct organization and workspace. In this model, users continue to work from the Terraform CLI, but plan and apply operations execute remotely in HCP Terraform. This provides centralized, encrypted state management and consistent execution without requiring manual uploads or a separate storage backend. This aligns with HashiCorp guidance for HCP Terraform remote operations and workspaces. Relevant documentation includes Terraform language configuration for the cloud block and HCP Terraform workflow documentation describing CLI-driven runs, remote execution, and managed state.

  • A. Incorrect.

    This is incorrect. A local backend keeps state on the user's machine unless separately moved, which does not provide the shared, managed remote execution model the scenario requires. Manually uploading state is error-prone and defeats the purpose of HCP Terraform's managed state and remote runs.

  • B. Correct.

    This is correct. Using the Terraform cloud block to connect the configuration to an HCP Terraform organization and workspace enables the CLI-driven remote workflow. Developers can still run Terraform commands locally, but HCP Terraform performs the remote plan and apply, manages encrypted state, and centralizes execution with minimal extra process overhead.

  • C. Incorrect.

    This is incorrect. HCP Terraform is more than a dashboard; it provides remote execution, workspace management, variables, policy integration, and managed state. Using S3 for state and HCP Terraform only for visibility does not satisfy the requirement that every plan and apply run remotely in HCP Terraform.

  • D. Incorrect.

    This is incorrect. HCP Terraform agents are used to enable HCP Terraform runs to access private network resources, not to turn each laptop into a local execution node. The scenario does not require private connectivity, and copying state after local execution would be a brittle workaround rather than a best-practice HCP Terraform workflow.

HashiCorp Terraform Associate (004) Question 204

Single answer8a Use HCP Terraform to create infrastructure

A platform team wants application developers to provision AWS infrastructure through HCP Terraform without installing the AWS CLI or storing long-lived AWS access keys on their laptops. The team also wants every infrastructure change to be tracked in a remote workflow with a plan shown before apply. Which approach best meets these requirements?

  1. A

    Create an HCP Terraform workspace connected to the VCS repository, store AWS credentials as workspace environment variables, and use remote execution so runs occur in HCP Terraform.

  2. B

    Require each developer to run terraform plan and terraform apply locally, then push the generated state file to HCP Terraform after the deployment completes.

  3. C

    Use local execution in the HCP Terraform workspace so plans run on each developer workstation, but configure HCP Terraform to display the results centrally after apply.

  4. D

    Commit AWS access keys into the Terraform configuration as input variables so HCP Terraform can reuse them consistently across workspaces.

Show answer and explanation

Correct answer: A

Explanation

The best solution is to use an HCP Terraform workspace with remote execution, typically connected to a version control repository. In this model, Terraform runs in HCP Terraform rather than on a developer laptop, which helps enforce a standard workflow and centralizes run history, plans, applies, and state management. Cloud provider credentials can be stored securely as sensitive workspace environment variables, allowing HCP Terraform to authenticate to AWS during runs without exposing long-lived secrets to developers. This aligns with HCP Terraform best practices for remote operations, workspace variable management, and VCS-driven workflows.

  • A. Correct.

    Correct. A VCS-connected workspace in HCP Terraform supports a remote workflow where commits trigger runs, HCP Terraform generates and displays the plan, and applies can be controlled centrally. Storing cloud credentials as sensitive environment variables in the workspace keeps them out of developer machines and source control. This is a common and recommended way to use HCP Terraform to create infrastructure.

  • B. Incorrect.

    Incorrect. This keeps execution on developer machines, which does not satisfy the requirement to avoid installing cloud tooling or handling credentials locally. It also misunderstands HCP Terraform workflows: state is managed remotely by the platform during runs, not by manually pushing a local state file after deployment.

  • C. Incorrect.

    Incorrect. Local execution means Terraform runs on the user's machine, so developers would still need local tooling and likely local credential access. HCP Terraform's main value here is remote execution with centralized plan/apply tracking, not merely displaying results after a local run.

  • D. Incorrect.

    Incorrect. Committing AWS access keys into Terraform code is a serious security anti-pattern. Secrets should not be stored in version control or plain input variables in configuration files. HCP Terraform provides secure workspace variables for sensitive values instead.

HashiCorp Terraform Associate (004) Question 205

Single answer8a Use HCP Terraform to create infrastructure

A platform team wants application developers to provision AWS infrastructure through HCP Terraform without needing the AWS CLI or local cloud credentials on their laptops. The team has already pushed the Terraform configuration to a VCS repository and connected that repository to an HCP Terraform workspace. They want plans and applies to run remotely in HCP Terraform whenever code is merged to the main branch. Which action should they take next to enable this workflow securely?

  1. A

    Configure the workspace to use remote execution and add the required AWS provider credentials as environment variables or a dynamic credentials integration in HCP Terraform

  2. B

    Require each developer to run terraform apply locally with their own AWS credentials, then upload the state file to HCP Terraform after the deployment completes

  3. C

    Store AWS access keys directly in Terraform variable values inside the configuration so HCP Terraform can read them during plan and apply

  4. D

    Disable VCS-driven runs and use terraform import from each developer workstation so HCP Terraform can infer the needed AWS permissions automatically

Show answer and explanation

Correct answer: A

Explanation

HCP Terraform can create infrastructure by running Terraform remotely in a workspace connected to a VCS repository. In this model, developers do not need local cloud credentials because the plan and apply occur in HCP Terraform's execution environment. To make that work, the workspace must be configured for remote execution and supplied with provider credentials securely, typically through environment variables marked sensitive or through supported dynamic credentials integrations. This aligns with HashiCorp best practices for VCS-driven workflows, remote operations, and secret handling. The other options reflect common misconceptions: local execution with manual state handling bypasses HCP Terraform's workflow controls, embedding credentials in code is insecure, and terraform import does not solve authentication or automated provisioning requirements.

  • A. Correct.

    Correct. To create infrastructure through HCP Terraform without requiring local cloud credentials, the workspace should use remote execution so Terraform runs in HCP Terraform's execution environment. HCP Terraform then needs access to provider credentials, commonly through workspace environment variables or, where supported, dynamic provider credentials. This is the standard secure pattern for VCS-driven workflows in HCP Terraform.

  • B. Incorrect.

    Incorrect. This defeats the goal of using HCP Terraform to centralize execution and avoid local cloud credentials. Uploading state after local applies is not the intended operational model for HCP Terraform remote runs and introduces drift, security, and process consistency problems.

  • C. Incorrect.

    Incorrect. Hardcoding cloud credentials in Terraform configuration or normal Terraform variables is an insecure practice. Secrets should not be committed to version control. HCP Terraform supports sensitive variables and environment variables, and best practice is to use those or dynamic credentials instead of embedding secrets in code.

  • D. Incorrect.

    Incorrect. terraform import is used to bring existing infrastructure under Terraform management, not to grant provider permissions or replace normal plan/apply workflows. Disabling VCS-driven runs also conflicts with the team's requirement to trigger remote runs automatically from merges to the main branch.

Timed practice exam

Take a HashiCorp Terraform Associate (004) practice test under exam conditions

70 questions in 60 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam

HashiCorp Terraform Associate (004) practice questions 201 to 223 of 223

Every question has a page with the answer and explanation. Numbers are stable, so you can bookmark or share them. The bank is split into 3 pages of up to 100 questions.

  1. 201.Your team has migrated a Terraform workflow from local execution to HCP Terraform. A workspace is configured...
  2. 202.Your team uses HCP Terraform to manage AWS infrastructure across development and production workspaces. A...
  3. 203.A platform team is migrating local Terraform workflows to HCP Terraform. They want every plan and apply to...
  4. 204.A platform team wants application developers to provision AWS infrastructure through HCP Terraform without...
  5. 205.A platform team wants application developers to provision AWS infrastructure through HCP Terraform without...
  6. 206.A platform team wants developers to provision AWS infrastructure through HCP Terraform without storing...
  7. 207.A platform team is moving from local Terraform CLI runs to HCP Terraform so they can standardize deployments...
  8. 208.A platform team is moving from local Terraform CLI workflows to HCP Terraform so that all infrastructure...
  9. 209.A platform team uses HCP Terraform to manage infrastructure for several application teams. They want every...
  10. 210.A platform team uses HCP Terraform to manage infrastructure for multiple application teams. They want...
  11. 211.A platform team is moving Terraform workflows from local execution to HCP Terraform. They want application...
  12. 212.A platform team is using HCP Terraform to manage infrastructure for several application teams. They want...
  13. 213.A platform team uses HCP Terraform to manage infrastructure for several application teams. They want...
  14. 214.A platform team is migrating several Terraform configurations into HCP Terraform. They want to group related...
  15. 215.A platform team is onboarding HCP Terraform for three application teams. Each application has separate dev,...
  16. 216.A platform team is onboarding HCP Terraform for three application teams: Payments, Analytics, and Search....
  17. 217.A platform team is migrating from local Terraform execution to HCP Terraform. They support three application...
  18. 218.A platform team is moving from local Terraform execution to HCP Terraform. They manage infrastructure for...
  19. 219.A team currently runs Terraform locally from engineers' laptops and wants to standardize execution in HCP...
  20. 220.A team currently runs Terraform locally against AWS, but they want HCP Terraform to execute plans and applies...
  21. 221.A platform team wants all Terraform operations for a production AWS workspace to run remotely in HCP...
  22. 222.A platform team is migrating from local Terraform execution to HCP Terraform. They want all plans and applies...
  23. 223.A team currently runs Terraform locally from developer laptops, but they want all plans and applies to...