0
0
Terraformcloud~10 mins

Module registry for organization in Terraform - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Module registry for organization
Create Module Code
Publish Module to Org Registry
Module Available in Registry
Use Module in Terraform Config
Terraform Init Downloads Module
Terraform Apply Uses Module
This flow shows how you create a module, publish it to your organization's registry, then use it in Terraform configurations.
Execution Sample
Terraform
terraform {
  required_providers {
    aws = { source = "hashicorp/aws" }
  }
}

module "vpc" {
  source = "app.terraform.io/org-name/vpc/aws"
  version = "1.0.0"
}
This Terraform config uses a module named 'vpc' from the organization's module registry.
Process Table
StepActionInput/ConditionResult/Output
1Create module code locallyWrite reusable Terraform codeModule files ready for publishing
2Publish modulePush module to org registry with version 1.0.0Module stored in org registry
3Write Terraform configReference module source as org registry pathConfig ready to use module
4Run terraform initDetect module sourceModule downloaded from org registry
5Run terraform applyUse downloaded moduleResources created as defined by module
6EndAll steps completeInfrastructure deployed using org module
💡 All steps complete, module used successfully from organization registry
Status Tracker
VariableStartAfter Step 3After Step 4Final
module_codeNot createdCreated and publishedDownloaded by terraform initUsed in terraform apply
terraform_configNot writtenWritten with module sourceInitialized with moduleApplied to create resources
Key Moments - 3 Insights
Why do we need to publish the module to the organization registry before using it?
Because terraform init downloads modules from the registry. Without publishing, terraform cannot find or download the module (see execution_table step 2 and 4).
What does the 'source' attribute in the module block represent?
It tells Terraform where to find the module code. For organization registry modules, it uses the format 'app.terraform.io/org-name/module-name/provider' (see execution_table step 3).
What happens if the module version is not specified?
Terraform will use the latest version available in the registry, but specifying a version ensures consistent and repeatable deployments (related to step 3 in execution_table).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step is the module code downloaded to your local machine?
AStep 3
BStep 2
CStep 4
DStep 5
💡 Hint
Check the 'Result/Output' column for step 4 in the execution_table.
According to the variable tracker, what is the state of 'terraform_config' after step 3?
AWritten with module source
BNot written
CInitialized with module
DApplied to create resources
💡 Hint
Look at the 'terraform_config' row and the 'After Step 3' and 'After Step 4' columns in variable_tracker.
If you skip publishing the module (step 2), what will happen during terraform init (step 4)?
AModule downloads successfully
BTerraform init fails to find the module
CTerraform apply creates resources anyway
DModule version defaults to latest
💡 Hint
Refer to the key_moments explanation about publishing before usage.
Concept Snapshot
Module registry for organization:
- Create reusable Terraform module code
- Publish module to your organization's registry with version
- Reference module in Terraform config using org registry source
- Run 'terraform init' to download module
- Run 'terraform apply' to deploy resources
- Versioning ensures consistent deployments
Full Transcript
This visual execution shows how to use a module registry for your organization in Terraform. First, you create module code locally. Then you publish it to your organization's registry with a version number. Next, you write a Terraform configuration that references the module using the registry source path. When you run 'terraform init', Terraform downloads the module from the registry. Finally, 'terraform apply' uses the module to create infrastructure resources. The variable tracker shows the state changes of module code and Terraform config through these steps. Key moments clarify why publishing is necessary and how the source attribute works. The quiz tests understanding of when the module is downloaded, the state of the config, and consequences of skipping publishing.