Provider configuration and schemas
What a provider does
A provider connects Terraform to a particular system. Terraform evaluates configuration and coordinates changes; a provider supplies the operations and data types for its target system. For example, an infrastructure provider can translate a requested server into API operations. A provider is executable software, not merely an HCL file. The built-in Terraform provider used in earlier local labs needs no separately installed plugin.
Identify a provider and select a configuration
Read this invented configuration as an illustration only. The demo provider, its version, regions and resource types are fictional; do not initialize or execute it.
terraform { required_providers { demo = { source = "registry.example.com/learning/demo" version = "= 1.0.0" } }}provider "demo" { region = "north"}provider "demo" { alias = "south" region = "south"}resource "demo_service" "catalog" { provider = demo.south name = "catalog-test"}The source identifies the publisher and provider type within a registry. demo is the module-local name. The version constraint requests a plugin release, not a Terraform CLI release. The two provider blocks configure the same provider differently. demo.south selects the named configuration for catalog; an unqualified demo resource would normally use the default. The unquoted provider reference is not a region string. If all configurations have aliases, the implicit default is empty and may fail if required settings are absent.
Read a resource schema
A schema describes the permitted inputs, returned attributes, types and nested structures for a particular resource. HCL can parse a perfectly shaped block that the provider rejects because a field is unsupported. Here is an invented, abbreviated attribute dictionary for demo_service (not actual CLI output):
{ "name": { "type": "string", "required": true }, "network_id": { "type": "string", "optional": true }, "id": { "type": "string", "computed": true }}name must be supplied, network_id may be omitted, and the computed-only id is supplied by the provider rather than set by the learner. A real attribute may be both optional and computed. A sensitive marking is not proof of encryption. Read the exact provider version documentation for constraints not represented in this simplified schema.
Inspect approved schemas without changing infrastructure
In a reviewed, initialized lab with trusted installed plugins, terraform providers lists provider requirements and terraform providers schema -json provides machine-readable schemas. These commands do not request resource creation, but schema inspection can load provider code. Do not initialize the fictional provider above or run unknown binaries. Check plugin provenance and the lab backend first. A schema inspection does not prove that the target account has permission or that an API operation will succeed.
Separate Terraform syntax from provider behavior
The resource block and provider meta-argument belong to Terraform. A field such as region, name or network_id depends on the selected provider and resource schema. Prefer explicit source addresses and keep credentials out of configuration and shell history. Put provider version requirements under required_providers, not the deprecated version argument of a provider configuration. Version selection and lockfiles are covered in the next chapter after resource and data-source fundamentals.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Provider configuration and schemas — knowledge check
Check provider configuration, schemas and lifecycle ownership.
What identifies the provider distribution?
What does demo.south select?
Which field is computed-only in the synthetic schema?
Does parsing HCL prove that a provider supports every field?
Where should new provider version constraints be declared?