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
provideris set. - Declare providers in
required_providersinside theterraformblock; a source is[hostname/]namespace/typeand defaults toregistry.terraform.ioand, when absent, tohashicorp/<local name>. ~> 3.6.0allows 3.6.x only;~> 3.6allows anything from 3.6 up to but excluding 4.0. Reusable modules set a minimum with>=only.terraform initinstalls providers into.terraform/providersand writes.terraform.lock.hcl; later inits reuse the locked version;init -upgrademoves to the newest allowed.
Try a question
Which statement about a provider's version argument is correct for current Terraform?
- AThe version argument is required for every provider block, and terraform init fails with an error without it
- BConstraints belong in required_providers; the version argument in a provider block is deprecated
- CVersion constraints may only be set inside provider blocks, not in the terraform block
- 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.