0
0
Terraformcloud~10 mins

Dependency inversion with modules in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a module source.

Terraform
module "network" {
  source = [1]
}
Drag options to blanks, or click blank then click option'
A"aws_network"
B"./modules/network"
C"network-module"
D"terraform-network"
Attempts:
3 left
💡 Hint
Common Mistakes
Using module names instead of paths for source
Omitting quotes around the source path
2fill in blank
medium

Complete the code to pass a variable to a module.

Terraform
module "compute" {
  source = "./modules/compute"
  instance_type = [1]
}
Drag options to blanks, or click blank then click option'
At2_micro
Bt2.micro
C"t2.micro"
Dt2micro
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around string values
Using underscores instead of dots in instance type
3fill in blank
hard

Fix the error in the module output reference.

Terraform
output "subnet_id" {
  value = module.network.[1]
}
Drag options to blanks, or click blank then click option'
AsubnetId
Bsubnetid
CsubnetID
Dsubnet_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or PascalCase instead of snake_case
Mismatching output names with module definitions
4fill in blank
hard

Fill both blanks to define a module with variables and outputs correctly.

Terraform
module "storage" {
  source = [1]
  bucket_name = [2]
}
Drag options to blanks, or click blank then click option'
A"./modules/storage"
B"storage-bucket"
C"bucket-storage"
D"./modules/bucket"
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing module source with bucket name
Not quoting string values
5fill in blank
hard

Fill all three blanks to output a module's attribute with correct syntax.

Terraform
output "db_endpoint" {
  value = module.[1].[2]_[3]
}
Drag options to blanks, or click blank then click option'
Adatabase
Bendpoint
Curl
Ddb
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong module name
Mixing up attribute parts or missing underscores