module "db" {
source = "app.terraform.io/myorg/db/aws"
version = "1.0"
}
Terraform fails with an error about version format. What is the likely problem?
medium
A. Version should be a full semantic version like "1.0.0"
B. Source URL is missing the organization name
C. Module name "db" is invalid
D. Version attribute is not supported in module blocks
Solution
Step 1: Check version format requirements
Terraform module versions must follow semantic versioning, e.g., "1.0.0".
Step 2: Identify the error cause
Using "1.0" is incomplete and causes a format error.
Final Answer:
Version should be a full semantic version like "1.0.0" -> Option A
Quick Check:
Version format = semantic (x.y.z) [OK]
Hint: Use full semantic version (e.g., 1.0.0) [OK]
Common Mistakes:
Using short version like 1.0 instead of 1.0.0
Forgetting organization name in source
Thinking version attribute is invalid
5. Your team wants to ensure all Terraform modules used from the organization registry are locked to specific versions to avoid unexpected changes. Which practice should you follow?
hard
A. Remove the version attribute and rely on Terraform to pick stable versions
B. Use the latest version without specifying version to get updates automatically
C. Specify exact module versions in the module block using the version attribute
D. Download modules manually and use local paths instead of registry
Solution
Step 1: Understand version locking importance
Locking module versions prevents unexpected changes and keeps infrastructure stable.
Step 2: Apply version locking in Terraform
Use the version attribute in the module block to specify exact versions from the registry.
Final Answer:
Specify exact module versions in the module block using the version attribute -> Option C
Quick Check:
Version attribute locks module version [OK]
Hint: Always specify exact version to lock modules [OK]
Common Mistakes:
Using latest version without locking causes surprises
Thinking manual download is better than registry
Removing version attribute leads to unstable infra