0
0
Terraformcloud~10 mins

Module structure and conventions 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 a Terraform module source path.

Terraform
module "example" {
  source = "[1]"
}
Drag options to blanks, or click blank then click option'
Aterraform-example
Bexample-module
C./modules/example
D/modules/example
Attempts:
3 left
💡 Hint
Common Mistakes
Using just the module name without a path.
Starting the path with a slash which makes it absolute instead of relative.
2fill in blank
medium

Complete the code to declare a variable inside a Terraform module.

Terraform
variable "region" {
  type    = string
  default = "[1]"
}
Drag options to blanks, or click blank then click option'
Aus-east-1
Bregion-1
Cdefault-region
Dus-west-2
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid or placeholder strings that are not real regions.
Leaving the default empty or missing.
3fill in blank
hard

Fix the error in the module output declaration.

Terraform
output "instance_id" {
  value = [1]
}
Drag options to blanks, or click blank then click option'
Aexample.id
Baws_instance.example
Cinstance.id
Daws_instance.example.id
Attempts:
3 left
💡 Hint
Common Mistakes
Referencing the resource without the attribute.
Using incomplete or incorrect resource names.
4fill in blank
hard

Fill both blanks to create a module call with a variable and output.

Terraform
module "web_server" {
  source = "[1]"
  region = var.[2]
}
Drag options to blanks, or click blank then click option'
A./modules/webserver
Bregion
Cwebserver
D./webserver
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect source paths.
Passing variables without the var. prefix.
5fill in blank
hard

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

Terraform
module "db" {
  source = "[1]"
  db_name = var.[2]
  db_port = var.[3]
}
Drag options to blanks, or click blank then click option'
A./modules/database
Bname
Cport
D./database
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect source paths.
Mismatching variable names between module and call.