Skill 2.1.1

Declaring provider requirements

Key Concepts

The required_providers block maps a local name, which the rest of the module uses, to a source address and a version constraint. For example, aws = { source = "hashicorp/aws", version = "~> 6.0" }. The source address has the form [HOSTNAME/]NAMESPACE/TYPE; the hostname defaults to registry.terraform.io, the public Terraform Registry.

The terraform block can also set required_version, a constraint on the Terraform CLI itself, such as ">= 1.12.0". If the running CLI does not satisfy it, Terraform stops with an error before doing anything. If a module uses a provider without declaring it, Terraform assumes the source hashicorp/<local name>, which is wrong for partner and community providers, so always declare every provider explicitly.