What keyword is used to declare a new module in a Terraform configuration file?

Master the HashiCorp Terraform Test with these flashcards and multiple choice questions. Each question includes hints and explanations to prepare you effectively. Set yourself up for success!

The keyword used to declare a new module in a Terraform configuration file is "module." In Terraform, modules serve as containers for multiple resources and can be used to manage related resources as a single entity. When you declare a module, you typically specify its source (which may be a path to local files, a Git repo, or a Terraform Registry module), and you can also pass variables to that module.

Utilizing modules promotes code reusability and organization, allowing you to abstract configurations that can be reused across different parts of your infrastructure. This improves maintainability and clarity in your Terraform code by segmenting functionality into manageable components.

Other keywords like "resource," "provider," and "import" serve different purposes within a Terraform configuration. "Resource" is used to define specific infrastructure components and their properties, "provider" specifies the plugin required to interact with a particular cloud service or API, and "import" is a command used to bring existing infrastructure into Terraform management rather than defining new modules or resources.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy