Complete the code to declare a module source.
module "network" { source = [1] }
The source attribute specifies the path to the module code. Using a relative path like "./modules/network" correctly points to a local module.
Complete the code to pass a variable to a module.
module "compute" { source = "./modules/compute" instance_type = [1] }
var. prefix.Module input variables require values as strings or expressions. Here, the instance type must be a string, so it needs quotes: "t2.micro".
Fix the error in the module call to correctly reference an output.
output "subnet_id" { value = module.network.[1] }
Module outputs are referenced by their exact output name. If the module defines an output named subnet_id, it must be referenced exactly as module.network.subnet_id.
Fill both blanks to create a module block with a variable and output reference.
module "storage" { source = [1] bucket_name = [2] } output "bucket" { value = module.storage.bucket_name }
The source must be a path string to the module. The bucket_name variable is set to a string value representing the bucket's name.
Fill all three blanks to define a module with variables and use an output in another resource.
module "db" { source = [1] db_name = [2] db_user = [3] } resource "aws_db_instance" "main" { identifier = module.db.db_name username = module.db.db_user engine = "mysql" instance_class = "db.t3.micro" }
The source is the path to the database module. The variables db_name and db_user are set to string values representing the database name and user.