0
0
Terraformcloud~10 mins

Root module concept 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 define the root module source.

Terraform
module "network" {
  source = "[1]"
}
Drag options to blanks, or click blank then click option'
Aroot_module
Baws_vpc
Cterraform
D./modules/network
Attempts:
3 left
💡 Hint
Common Mistakes
Using a provider name instead of a path.
Using 'root_module' as source which is not valid.
2fill in blank
medium

Complete the code to declare a variable in the root module.

Terraform
variable "region" {
  type    = string
  default = "[1]"
}
Drag options to blanks, or click blank then click option'
Amodule
Bus-east-1
Cterraform
Droot
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'terraform' or 'module' as a region value.
Leaving the default empty.
3fill in blank
hard

Fix the error in the root module output block.

Terraform
output "vpc_id" {
  value = module.network.[1]
}
Drag options to blanks, or click blank then click option'
Avpcid
BvpcId
Cvpc_id
DVpcId
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or PascalCase instead of snake_case.
Misspelling the attribute name.
4fill in blank
hard

Fill both blanks to correctly pass a variable from the root module to a child module.

Terraform
module "compute" {
  source = "./modules/compute"
  [1] = var.[2]
}
Drag options to blanks, or click blank then click option'
Aregion
Binstance_type
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing variable names between left and right sides.
Using the wrong variable names.
5fill in blank
hard

Fill all three blanks to define an output in the root module that references a child module's output.

Terraform
output "[1]" {
  value = module.compute.[2]
  description = "[3]"
}
Drag options to blanks, or click blank then click option'
Ainstance_id
CID of the compute instance
DCompute instance ID
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching output names and values.
Leaving description empty or unclear.