Create unique terraform modules and upload on public terraform registry.

Sandeshjain
3 min readSep 7, 2022

What is terraform module ?

A module can be any folder with a main.tf file in it, yes, that is the only required file for a module to be usable, but the recommendation is that you also put a README.md file with a description of the module if it’s intended to be used by people if it’s a sub-module it’s not necessary, also you will need a file called variables.tf and other outputs.tf of course if it’s a big module that cannot be split into sub-modules you can split those files for convenience or readability, variables should have descriptions so the tooling can show you what are they for.

Create a Terraform Module

Terraform Module files are just standard HCL resource declarations which take input variables, and usually output variables as well. You can provision them into your root TF file(s), passing in the variables they need, and they will create resources based on those variables assigning values for output variables accordingly. The main thing to note here, is that resources created by modules exist in the module’s namespace.

C:/Users/user/Desktop/Gaurav/modules/vm#this is the path where i keep all my module path

NOW we will type the command terraform init because when ever we use module we have to use init to initialize it

Thank You!!

--

--