liveBook · Manning

Terraform module registry

As explained in Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

Terrareg is open-source software for hosting and distributing Terraform modules through a private registry.

A Terraform module registry solves a practical distribution problem: reusable modules need dependable versioning and an easy way for teams to consume them. Terrareg is open-source software for hosting and distributing modules through a private registry. section 8.1 section 8.1.4

Registries commonly connect to source control and publish releases when tags are created. Teams can then download released module versions rather than continually tracking changing source branches. section 3.1.5 section 8.1.2

A private Terraform registry typically involves these operational pieces:

  • Connect the registry to the organization’s source-control management system and create tags to publish module releases. section 8.1.4
  • Have users authenticate with terraform login so Terraform can obtain a token and download private modules. section 3.1.5 section 8.1.4
  • Prefer registry delivery as module usage grows, because version constraints scale better than manually coordinating direct SCM sources. section 8.1.2
  • Treat self-hosting as a cost-and-effort decision: Terrareg avoids commercial license fees but requires more operational work than a commercial service. section 8.1.4
Listing 8.4 Logging into a private registry
% terraform login registry.example.com                                  #1
Terraform will request an API token for registry.example.com using your 
browser.                                                              #2
 
If login is successful, Terraform will store the token in plain text in
the following file for use by subsequent commands:
    /Users/tid/.terraform.d/credentials.tfrc.json
 
Do you want to proceed?
  Only 'yes' will be accepted to confirm.
 
  Enter a value: yes                                                    #3
 
 
----------------------------------------------------------------------------
 
Terraform must now open a web browser to the tokens page for 
registry.example.com.
 
If a browser does not open this automatically, open the following URL 
to proceed: 
 
https://registry.example.com/app/settings/tokens?source=terraform-login #4
 
 
----------------------------------------------------------------------------
 
Generate a token using your browser, and copy-paste it into this prompt.
 
Terraform will store the token in plain text in the following file
for use by subsequent commands:
    /Users/tedivm/.terraform.d/credentials.tfrc.json
 
Token for registry.example.com:
  Enter a value:                                                        #5
 
 
Retrieved token for user terraformindepth                               #6
#1 If you don’t specify a registry, then HCP Terraform is used.
#2 Terraform lets you know it will open a browser for login.
#3 You must confirm before continuing.
#4 If your terminal doesn’t allow programs to open browsers, you have to copy and paste this into one yourself.
#5 Finally, you have to enter the value that you received from your login flow.
#6 Terraform will confirm the user you are logging in as. This may be slightly different for your registry, as each registry can response with it’s own confirmation text.

Inspect the private-registry login flow, including browser-based API-token retrieval and the local credentials file used by subsequent Terraform commands. section 8.1.4

How Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu covers it

How deep it goes
Explains registry workflows, SCM integration, authentication, and tradeoffs, but stops short of Terrareg deployment details.
Examples
Uses tagged releases, direct Git sources, bugfix branches, and terraform login against a private registry.
What it assumes
Assumes familiarity with Terraform modules and source control while contrasting direct SCM usage with registry-based delivery.
What you can do after
Operate/configure authenticated private module consumption and evaluate Terrareg against commercial registry services.
How it connects
Connects Terraform modules with version control, source-control management, version constraints, private registries, Terraform Cloud, and Spacelift.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu. The section links point to the parts of the book it draws on.