You have a Terraform root module and want to include a child module located in a folder named modules/network. Which source value correctly references this child module?
Think about the path relative to the root module where you call the child module.
The source path for a child module is relative to the root module's directory. Using "./modules/network" correctly points to the modules/network folder inside the root module.
You want to pass a variable named region with value "us-west-2" to a child module. Which is the correct way to do this in the root module?
module "child" { source = "./modules/child" // pass region here }
Variables are passed by naming them directly inside the module block.
To pass variables to a child module, you assign values directly using the variable name as the key inside the module block.
A child module outputs a value named subnet_id. How do you correctly reference this output in the root module?
output "subnet_id" {
value = module.child.subnet_id
}Outputs from child modules are accessed using module..
To get an output from a child module, you use module.child.subnet_id where child is the module block name.
You have a child module that outputs a sensitive value like a password. What is the best way to prevent this sensitive output from showing in the root module's plan or apply output?
Terraform has a built-in way to mark outputs as sensitive.
Marking an output as sensitive = true tells Terraform to hide its value in CLI output and logs, protecting sensitive data.
You update the source path of a child module in your root module to point to a different folder with a different resource configuration. What happens when you run terraform apply?
Think about how Terraform tracks resources by module source paths.
Changing the source path makes Terraform see the child module as different. It creates new resources but does not remove old ones automatically, causing orphaned resources unless manually handled.