<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Terraform Module on Sagar Panda | DevOps &amp; Cloud Engineer</title><link>https://sagarpanda.com/tags/terraform-module/</link><description>Recent content in Terraform Module on Sagar Panda | DevOps &amp; Cloud Engineer</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 22 Dec 2024 19:26:10 +0530</lastBuildDate><atom:link href="https://sagarpanda.com/tags/terraform-module/index.xml" rel="self" type="application/rss+xml"/><item><title>Terraform Modules - Simplify, Organise and Reuse Your IAC</title><link>https://sagarpanda.com/blogs/terraform/tf-module/</link><pubDate>Sun, 22 Dec 2024 19:26:10 +0530</pubDate><guid>https://sagarpanda.com/blogs/terraform/tf-module/</guid><description>&lt;p&gt;A &lt;strong&gt;Terraform module&lt;/strong&gt; is a container/template for multiple resources that are used together. Modules are a way to organize and reuse code in Terraform, making infrastructure management more efficient and maintainable.&lt;/p&gt;
&lt;p&gt;We first define the resource templates, and then we call the templates from outside of the module structures and we can even modify them as per our needs.&lt;/p&gt;
&lt;p&gt;A typical module module looks something this this:&lt;/p&gt;
&lt;div
 class="code-block-container border-border bg-card my-6 overflow-hidden rounded-xl border shadow-sm transition-all duration-200 ease-out hover:-translate-y-0.5 hover:shadow-md"
 data-code-block
 data-code-id="code-0"
 data-collapsible="true"
 data-default-state="expanded"
 data-collapsed="false"
 data-auto-collapse-lines="30"
 data-auto-collapse-height="400"
 data-collapsed-height="120"
&gt;
 
 &lt;div
 class="code-block-header bg-muted/30 border-border flex items-center justify-between border-b px-4 py-3"
 &gt;
 
 &lt;div class="flex items-center gap-2"&gt;
 &lt;div class="text-muted-foreground shrink-0"&gt;
 &lt;svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;
 &lt;path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" /&gt;
&lt;/svg&gt;
 &lt;/div&gt;
 &lt;span class="text-muted-foreground text-sm font-medium"&gt;
 PLAINTEXT
 &lt;/span&gt;
 &lt;/div&gt;

 
 &lt;div class="flex items-center gap-2"&gt;
 &lt;button
 class="collapse-code-btn text-muted-foreground hover:text-primary hover:bg-primary/10 focus:ring-primary/20 flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-all duration-200 ease-out focus:ring-2 focus:outline-none"
 type="button"
 data-code-action="toggle-collapse"
 data-label-expand="Expand"
 data-label-collapse="Collapse"
 title="Collapse"
 aria-label="Collapse"
 aria-controls="code-0"
 aria-expanded="true"
 &gt;
 &lt;span class="collapse-chevron transition-transform duration-200 ease-out"&gt;
 &lt;svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;
 &lt;path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /&gt;
&lt;/svg&gt;
 &lt;/span&gt;
 &lt;span class="collapse-text hidden sm:inline"&gt;Collapse&lt;/span&gt;
 &lt;/button&gt;
 &lt;button
 class="copy-code-btn text-muted-foreground hover:text-primary hover:bg-primary/10 focus:ring-primary/20 flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-all duration-200 ease-out focus:ring-2 focus:outline-none"
 type="button"
 data-code-action="copy"
 data-label-copy="Copy"
 data-label-copied="Copied"
 title="Copy"
 aria-label="Copy"
 &gt;
 &lt;span class="copy-icon"&gt;
 &lt;svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;
 &lt;path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" /&gt;
&lt;/svg&gt;
 &lt;/span&gt;
 &lt;span class="copy-text hidden sm:inline"&gt;Copy&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;/div&gt;

 
 &lt;div class="code-block-content relative" id="code-0"&gt;
 &lt;pre tabindex="0"&gt;&lt;code&gt;.
├── main.tf
├── outputs.tf
├── README.md
└── variables.tf&lt;/code&gt;&lt;/pre&gt;
 &lt;div hidden data-code-source&gt;.
├── main.tf
├── outputs.tf
├── README.md
└── variables.tf&lt;/div&gt;
 
 &lt;div
 class="collapse-overlay to-card/90 pointer-events-none absolute inset-0 bg-linear-to-b from-transparent via-transparent opacity-0 transition-opacity duration-300"
 hidden
 &gt;
 &lt;button
 class="collapse-overlay-btn text-muted-foreground bg-card/80 border-border/50 hover:bg-primary/10 hover:text-primary hover:border-primary/30 absolute bottom-4 left-1/2 flex -translate-x-1/2 items-center justify-center rounded-full border p-2 backdrop-blur-sm transition-all duration-200"
 type="button"
 data-code-action="expand"
 aria-label="Expand"
 title="Expand"
 &gt;
 &lt;svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;
 &lt;path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /&gt;
&lt;/svg&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;</description></item></channel></rss>