Which statement best explains why Terraform modules enable reusability?
Think about how grouping code helps avoid repeating the same instructions.
Terraform modules group related configuration so you can reuse the same setup multiple times by changing inputs, avoiding duplication.
You want to deploy three virtual machines with similar settings but different names and IPs. How can Terraform modules help?
Think about how calling the same code with different inputs saves effort.
Modules let you define a VM once and reuse it multiple times by passing different variables, making your code cleaner and easier to maintain.
Given the module call below, what is the value of module.webserver.instance_count after applying?
module "webserver" { source = "./modules/server" instance_count = 3 server_name = "web-prod" } output "instance_count" { value = module.webserver.instance_count }
Check how the input variable instance_count is passed and output is defined.
The module receives instance_count=3 and outputs it, so the value is 3.
Which option best describes how using modules can enhance security in Terraform infrastructure code?
Think about how reusing code can reduce errors and improve control.
By centralizing sensitive settings in modules, you reduce duplication and risk of exposing secrets or misconfigurations.
You have a Terraform module used in multiple places. You update the module code to change a resource property. What is the expected behavior when you run terraform apply in a project using this module?
Consider how Terraform tracks resource state and module code.
Terraform compares the current state with the updated module code and applies necessary changes to keep infrastructure in sync.