0
0
Terraformcloud~20 mins

Module versioning in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
πŸŽ–οΈ
Module Versioning Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Configuration
intermediate
2:00remaining
Terraform Module Version Pinning Behavior

Given the Terraform module source declaration below, what version of the module will Terraform use when you run terraform init?

module "network" {
  source  = "terraform-aws-modules/vpc/aws"
  version = ">= 2.0, < 3.0"
  name    = "my-vpc"
  cidr    = "10.0.0.0/16"
}
AThe latest available module version between 2.0 (inclusive) and 3.0 (exclusive)
BAlways version 2.0 exactly
CThe latest available module version regardless of version constraints
DThe latest available module version less than 2.0
Attempts:
2 left
πŸ’‘ Hint

Think about how version constraints work in Terraform module sources.

❓ service_behavior
intermediate
2:00remaining
Effect of Module Version Change on Terraform Plan

You have a Terraform configuration using a module pinned to version 1.5.0. You update the version to 1.6.0 and run terraform plan. What will happen?

ATerraform will fail with a version conflict error
BTerraform will ignore the version change and plan no changes
CTerraform will detect changes in the module and show resource changes if any exist between versions
DTerraform will automatically upgrade all resources without showing a plan
Attempts:
2 left
πŸ’‘ Hint

Consider how Terraform handles module upgrades during planning.

❓ Architecture
advanced
3:00remaining
Managing Multiple Module Versions in a Large Terraform Codebase

You manage a large Terraform codebase with multiple teams. Some teams require different versions of the same module. What is the best architecture to support this?

AUse separate module blocks with explicit version pins for each team’s requirements
BFork the module repository for each team and manage versions independently
CUse a single module block with the latest version and force all teams to upgrade simultaneously
DAvoid versioning and always use the module’s main branch
Attempts:
2 left
πŸ’‘ Hint

Think about how Terraform modules and versioning can coexist in one codebase.

❓ security
advanced
2:00remaining
Security Risks of Using Unpinned Module Versions

What is a key security risk of using Terraform modules without specifying a fixed version?

ATerraform will refuse to run without a pinned version
BUnexpected module updates could introduce malicious code or vulnerabilities
CModules without versions cannot be downloaded from registries
DThere is no security risk; always using latest is safest
Attempts:
2 left
πŸ’‘ Hint

Consider what happens if a module changes unexpectedly.

βœ… Best Practice
expert
3:00remaining
Best Practice for Module Versioning in CI/CD Pipelines

In a CI/CD pipeline deploying Terraform infrastructure, what is the best practice regarding module versioning to ensure stable and repeatable deployments?

ADo not specify versions and rely on the latest module code from the registry
BUse version constraints with ranges to always get the latest compatible module
CManually copy module code into the repository to avoid versioning
DPin exact module versions in the configuration and update them only after testing
Attempts:
2 left
πŸ’‘ Hint

Think about stability and repeatability in automated deployments.