Difference between revisions of "Writing a Terraform Module"

From NovaOrdis Knowledge Base
Jump to: navigation, search
(Procedure)
(Standard Structure)
Line 23: Line 23:
 
Everything is optional, except for the [[#Root_Module|root module]]:
 
Everything is optional, except for the [[#Root_Module|root module]]:
  
* <span id='Root_Module'></font>'''Root module''' - this is the only required element for the standard module structure, and it consists in .tf files - which must exist - in the root directory of the module.
+
* <span id='Root_Module'></span>'''Root module''' - this is the only required element for the standard module structure, and it consists in .tf files - which must exist - in the root directory of the module.
 
* README or README.md. Should contain a description of the module. Examples can be included in an example directory.
 
* README or README.md. Should contain a description of the module. Examples can be included in an example directory.
 
* LICENSE
 
* LICENSE

Revision as of 01:39, 14 November 2019

External

Internal

Reference Example

Playground

https://github.com/ovidiuf/playground/tree/master/hashicorp/terraform/blue-module

Procedure

To define a module, create a new root directory for it and place one or more .tf files inside it.

Standard Structure

Everything is optional, except for the root module:

  • Root module - this is the only required element for the standard module structure, and it consists in .tf files - which must exist - in the root directory of the module.
  • README or README.md. Should contain a description of the module. Examples can be included in an example directory.
  • LICENSE
  • Recommended file names:
    • main.tf
    • variables.tf
    • outputs.tf