Terraform Modules

Create, use, and manage reusable Terraform modules for infrastructure abstraction.

This domain covers Terraform modules as a way to package and reuse infrastructure configurations. It includes understanding how Terraform sources modules from various locations, describing variable scope within modules, using modules in configuration with the module block, and managing module versions to ensure consistent infrastructure deployments.
5 minutes 5 Questions

Terraform Modules are reusable, self-contained packages of Terraform configurations that encapsulate infrastructure resources into logical, manageable components. They serve as the primary method for organizing and reusing Terraform code across projects and teams. A module consists of a collection…

Concepts covered: Module sources and locations, Local and remote module sources, Terraform Registry modules, Git and version control module sources, Module input variables, Module output values, Variable encapsulation in modules, The module block syntax, Passing values to modules, Accessing module outputs, Module version constraints, Version pinning best practices

Test mode:
TA-004 - Terraform Modules Example Questions

Test your knowledge of Terraform Modules

Question 1

What is the primary mechanism for passing input values from a parent module to a child module in Terraform?

Question 2

You are a cloud infrastructure engineer at a transportation logistics company. Your team has developed a Terraform module called 'container-orchestration' that manages Kubernetes deployments. The module accepts a sensitive variable 'cluster_credentials' that should be marked as sensitive to prevent exposure in logs and state output. In your root module, you have the following configuration: variable "k8s_token" { type = string sensitive = true } variable "k8s_endpoint" { type = string sensitive = true } You need to pass both sensitive values to the child module which expects a single object variable defined as: variable "cluster_credentials" { type = object({ token = string endpoint = string }) sensitive = true } A team member is concerned about how sensitive values propagate through module boundaries. Which statement accurately describes how Terraform handles sensitive values when passed to child modules?

Question 3

A mid-sized retail company is migrating their infrastructure to Terraform. The infrastructure architect notices that a colleague has configured the required_providers block with version = '>= 4.0.0' for the AWS provider. During a team meeting, concerns are raised about potential instability when running terraform init in six months, as newer provider versions may introduce changes to resource behavior. The team wants to adopt version pinning best practices that balance stability with the ability to receive bug fixes. They are currently using AWS provider version 4.67.0 and want to stay within the 4.67.x patch releases only. Which version constraint should replace the current configuration?

More Terraform Modules questions
357 questions (total)