Complete the code to declare a module block in Terraform.
module "example" { source = [1] }
The source attribute specifies the path to the module folder, enabling reuse of that module.
Complete the code to pass a variable to a module.
module "example" { source = "./modules/example" instance_type = [1] }
Module input variables are assigned values using key = value pairs. The value must be a string if the variable expects a string.
Fix the error in the module output block.
output "instance_id" { value = module.example.[1] }
The output value references the module's output variable name, which is instance_id in this case.
Fill both blanks to define a reusable module with variables and outputs.
variable "[1]" { type = string } output "[2]" { value = var.[1] }
The variable name is instance_type, and the output returns a value named instance_id which could be set elsewhere in the module.
Fill all three blanks to call a module with variables and use its output.
module "web" { source = [1] instance_type = [2] } output "web_id" { value = module.web.[3] }
The module source is a local path, the instance type is a string, and the output references the module's output variable instance_id.