CertLumen

HashiCorp Terraform Associate (004) · Section 2 · 12% of the exam

Install and version Terraform providers

One of the objectives of the HashiCorp Certified: Terraform Associate (004) exam, in the section “Terraform fundamentals”. Here is what it covers, the points to remember and a question to try.

What it covers

Providers are the plugins that let Terraform talk to platforms. This lesson covers declaring them with required_providers, source addresses and version constraints, how init and the lock file install them, mirrors and caching, and how to configure several providers or several configurations of one provider, including in modules.

Points to remember

  • Providers are plugin executables; Terraform Core talks to them over RPC and never calls platform APIs itself.
  • The resource type prefix before the first underscore selects the provider unless provider is set.
  • Declare providers in required_providers inside the terraform block; a source is [hostname/]namespace/type and defaults to registry.terraform.io and, when absent, to hashicorp/<local name>.
  • ~> 3.6.0 allows 3.6.x only; ~> 3.6 allows anything from 3.6 up to but excluding 4.0. Reusable modules set a minimum with >= only.
  • terraform init installs providers into .terraform/providers and writes .terraform.lock.hcl; later inits reuse the locked version; init -upgrade moves to the newest allowed.

Try a question

Which statement about a provider's version argument is correct for current Terraform?

  1. AThe version argument is required for every provider block, and terraform init fails with an error without it
  2. BConstraints belong in required_providers; the version argument in a provider block is deprecated
  3. CVersion constraints may only be set inside provider blocks, not in the terraform block
  4. DThe version argument in a provider block overrides the version recorded in the lock file
Show the answer

B. Declaring constraints in required_providers keeps all requirements in one place and lets child modules and tooling read them without evaluating provider configuration.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson Terraform providers: install, version and combine teaches this objective (about 45 minutes), and 28 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 37 objectives · Next objective →