Complete the code to define a Terraform module source path.
module "example" { source = "[1]" }
The source attribute in a Terraform module block specifies the relative path to the module folder. Using ./modules/example correctly points to a local module.
Complete the code to declare a variable inside a Terraform module.
variable "region" { type = string default = "[1]" }
The default value for a variable sets the default region. us-east-1 is a common AWS region example.
Fix the error in the module output declaration.
output "instance_id" { value = [1] }
The output value must reference the resource attribute correctly. aws_instance.example.id accesses the instance ID attribute.
Fill both blanks to create a module call with a variable and output.
module "web_server" { source = "[1]" region = var.[2] }
var. prefix.The source should point to the local module folder ./modules/webserver. The variable region is passed from var.region.
Fill all three blanks to define a module with variables and outputs correctly.
module "db" { source = "[1]" db_name = var.[2] db_port = var.[3] }
The module source is ./modules/database. Variables db_name and db_port are passed from var.name and var.port respectively.