Terramate is a code generator and an orchestrator for terraform that adds some of the powerful capabilities that are code generation, change detection, globals and more to the terraform.
It uses the filesystem and its hierarchy and needs to know the project’s root.
Let’s start using Terramate, there are two possible ways for us of configuring a Terramate project. If we invoke Terramate inside a Git repository, Terramate will automatically assume the top-level of your repository as the project root. If we want to use Terramate in a directory that isn’t a Git repository, we must configure the project root by creating a terramate.tm.hcl configuration at the top level or any sub-directory in your Terramate project.
For this blog we will be using
A plain Terramate project without Git integration .To begin, create a new directory that contains a file named terramate.tm.hcl

Stack:
They are designed to break down your infrastructure into manageable codes, A terraform stack in a runnable terraform module

Use terramate create “name_of_the_stack” command to create a stack

Terramate recognizes all the files with the .tm or .tm.hcl extension, and any file containing a stack {} block is considered a stack.
- name = “newapp”: This is the name of the stack. It’s a string that identifies the stack .
- description = “newapp”: This is the description of the stack. It’s a string that provides additional information about the stack .
- id = “88e47847-c406-4b14-b450-d1211948e289”: This is the unique identifier of the stack. It’s a string that uniquely identifies the stack .
Code generator:
The code provided demonstrates how to generate an HCL file named mysite.tf that contains Terraform code for a local_file resource. To create the mysite.tf file, run the terramate generate



The Terraform.tf file is created as we used the command terramate generate.
We can now navigate to the directory, and execute terraform init and terraform apply to generate a local file in /tmp/tfmysite/index.html with the HTML code.
Terraform init:

Terraform apply:

Conclusion
This tutorial has helped us to grasp the basics of terramate and a few of its features and demonstrated how its simple code generation model works based on the filesystem hierarchy.