A local module source is a module stored on your computer or project folder. You use a relative or absolute path to include it in your Terraform configuration.
Click to reveal answer
beginner
How do you specify a registry module source in Terraform?
You specify a registry module source by using the module's name from the Terraform Registry, usually in the format namespace/name/provider. Terraform downloads it automatically.
Click to reveal answer
intermediate
What is the purpose of using a git module source in Terraform?
A git module source lets you use a module stored in a git repository. You provide the git URL, and optionally a branch, tag, or commit to use specific code versions.
Click to reveal answer
beginner
Example: How to reference a local module in Terraform?
Use source = "./modules/my_module" inside the module block to point to a folder named my_module inside a modules directory.
Click to reveal answer
intermediate
What is the syntax to use a git module source with a specific branch?
Use source = "git::https://github.com/user/repo.git?ref=branch-name" to get the module from a specific branch in the git repository.
Click to reveal answer
Which source format is used to include a module stored on your local machine?
AA relative or absolute file path
BA URL to a git repository
CA module name from Terraform Registry
DAn HTTP URL to a zip file
✗ Incorrect
Local modules use file paths to point to folders on your computer.
How do you specify a module from the Terraform Registry?
AUsing <namespace>/<name>/<provider> format
BUsing a path starting with ./ or ../
CUsing a git URL with ref parameter
DUsing an HTTP URL to a zip archive
✗ Incorrect
Registry modules use the format namespace/name/provider to identify modules.
What does the 'ref' parameter do in a git module source URL?
ADefines the module version in the registry
BSpecifies the branch, tag, or commit to use
CSets the local path for the module
DIndicates the provider for the module
✗ Incorrect
The 'ref' parameter tells Terraform which git branch, tag, or commit to use.
Which of these is a valid git module source URL?
Ahttps://example.com/module.zip
B./modules/my_module
Cgit::https://github.com/user/repo.git?ref=v1.0.0
Dhashicorp/aws
✗ Incorrect
Git module sources start with 'git::' followed by the repository URL and optional ref.
If you want to use a module stored in a folder named 'network' inside your project, what source do you use?
Anetwork
Bgit::network
Chashicorp/network/aws
D./network
✗ Incorrect
Local modules require a relative path starting with './' to specify the folder.
Explain the differences between local, registry, and git module sources in Terraform.
Think about where the module code is stored and how Terraform accesses it.
You got /3 concepts.
Describe how to specify a git module source with a specific branch in Terraform.
Remember the URL format and the ref parameter.
You got /3 concepts.
Practice
(1/5)
1. What does the source argument specify in a Terraform module block?
easy
A. The location where Terraform finds the module code
B. The version of Terraform to use
C. The cloud provider for the module
D. The output variables of the module
Solution
Step 1: Understand the role of source in a module
The source argument tells Terraform where to get the module code from, such as a local folder, registry, or Git repo.
Step 2: Identify what source does not specify
It does not specify Terraform version, cloud provider, or outputs; those are separate configurations.
Final Answer:
The location where Terraform finds the module code -> Option A
Quick Check:
Module source = module location [OK]
Hint: Remember: source means 'where to get the module' [OK]
Common Mistakes:
Confusing source with Terraform version
Thinking source defines outputs
Assuming source sets cloud provider
2. Which of the following is the correct syntax to use a local module located in a folder named modules/network?
easy
A. module "net" { source = "modules/network" }
B. module "net" { source = "registry/modules/network" }
C. module "net" { source = "git::https://example.com/network.git" }
D. module "net" { source = "network" }
Solution
Step 1: Identify local module source syntax
Local modules use a relative or absolute path as the source. Here, "modules/network" is a relative path.