When a Terraform workspace needs a provider or reusable module, the Terraform Public Registry supplies a public place to find it. Running terraform init downloads the workspace’s required providers from the registry and configures them locally. Provider documentation also exposes available resources, helping map a service’s capabilities before implementation. section 2.4.1
The registry fits Terraform’s provider model: Terraform Core translates configuration into provider operations, while providers handle communication with vendor systems. Providers can therefore be released independently of Terraform, and the registry makes thousands of provider interfaces available. section 1.2
Selecting a public module
A VPN capability can be added without building the implementation from scratch by declaring a registry module: module "vpn" { source = "tedivm/cloudinit/general" version = "~> 1.0" services = ["consul", "nomad"] } The source identifies the public module, while version constrains which releases Terraform may use. A version range gives the configuration control over when module updates are accepted. section 3.1.1
Publishing requires registering the repository once, then maintaining releases:
- Publish modules from a public GitHub repository; submit the repository to the registry and select it through the publishing workflow. section 8.1.3
- Create a properly semantic-versioned Git tag or release; the registry monitors the repository and adds new releases automatically. section 8.1.3
- Register a provider by adding a public signing key, selecting Publish and Provider, and connecting the provider repository; subsequent releases appear automatically. section 12.8.3
Listing 3.1 Using a public module
module "vpn" {
source = "tedivm/cloudinit/general" #1
version = "~> 1.0" #2
services = ["consul", "nomad"] #3
}
Inspect the annotated module declaration showing how source, version, and module arguments combine to consume a public registry module. section 3.1.1
