Courseiva
Use Terraform outside the core workflowhardMultiple ChoiceObjective-mapped

TF-004 Use Terraform outside the core workflow Practice Question

Exhibit

Refer to the exhibit.

```
Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/aws:
  could not connect to the registry: the request failed after 2 attempts, please check your internet connection
```

A user receives the error shown in the exhibit when running `terraform init`. The user is behind a corporate proxy. Which environment variable should be set to resolve this issue?

⚠ Common exam trap

HashiCorp often tests the distinction between Terraform-specific environment variables (like `TF_VAR_`) and standard system proxy variables, leading candidates to mistakenly choose `TF_VAR_proxy` as a Terraform-native proxy setting.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

HTTP_PROXY=http://proxy:8080

Terraform uses the standard `HTTP_PROXY` environment variable to route HTTP/HTTPS requests through a corporate proxy when downloading providers and modules. Setting `HTTP_PROXY=http://proxy:8080` instructs Terraform's underlying HTTP client to connect via the specified proxy, resolving the connectivity error during `terraform init`.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • TF_VAR_proxy=http://proxy:8080

    Why it's wrong here

    The `TF_VAR_` prefix is specifically designed to pass input variables into a Terraform configuration via environment variables. For instance, `TF_VAR_proxy` would define a variable named `proxy` within the Terraform configuration, accessible as `var.proxy`. This mechanism is intended for injecting configuration values *into* Terraform's processing logic, not for configuring the underlying network proxy settings that Terraform itself uses to make outbound HTTP/HTTPS requests to providers or remote state backends. Therefore, setting this variable will not resolve network connectivity issues related to proxying external network traffic.

  • AWS_ACCESS_KEY_ID

    Why it's wrong here

    The `AWS_ACCESS_KEY_ID` environment variable is a credential used by the AWS provider to authenticate and authorize API calls to Amazon Web Services. It identifies the access key associated with an IAM user or role, enabling Terraform to interact with AWS resources. While absolutely essential for Terraform to manage AWS infrastructure, this variable has no functional impact on configuring network proxy settings for outbound HTTP/HTTPS connections made by Terraform or its providers. It addresses authentication, not the network path through which requests are routed.

  • HTTP_PROXY=http://proxy:8080

    Why this is correct

    The `HTTP_PROXY` environment variable is a widely recognized standard that many applications, including Terraform and its providers, respect for configuring an HTTP proxy server. When set, Terraform will route its outgoing HTTP requests through the specified proxy server, enabling it to reach external endpoints that might otherwise be inaccessible due to network restrictions or firewalls. This is the correct and conventional method for configuring a network proxy for Terraform's HTTP communications, directly addressing connectivity errors in environments requiring proxy access.

  • TF_LOG=DEBUG

    Why it's wrong here

    The `TF_LOG` environment variable is used to control the verbosity of Terraform's logging output, with `DEBUG` providing the most detailed information about its operations. While setting `TF_LOG=DEBUG` can be extremely valuable for diagnosing *why* a connection is failing by providing extensive context in the logs, it does not *resolve* the underlying network connectivity issue itself. It is a diagnostic tool that helps identify the problem, such as a proxy configuration error, but it does not configure or establish the network connection through a proxy.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.