<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bipin Ghimire</title>
    <description>The latest articles on DEV Community by Bipin Ghimire (@bipin_ghimire_4b4cabb807c).</description>
    <link>https://dev.to/bipin_ghimire_4b4cabb807c</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2959370%2F63a2f013-8b13-4da7-8d92-40cda375635e.jpg</url>
      <title>DEV Community: Bipin Ghimire</title>
      <link>https://dev.to/bipin_ghimire_4b4cabb807c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bipin_ghimire_4b4cabb807c"/>
    <language>en</language>
    <item>
      <title>A Comprehensive Guide to Infrastructure as Code (IaC) Using Terraform</title>
      <dc:creator>Bipin Ghimire</dc:creator>
      <pubDate>Thu, 20 Mar 2025 05:20:44 +0000</pubDate>
      <link>https://dev.to/bipin_ghimire_4b4cabb807c/a-comprehensive-guide-to-infrastructure-as-code-iac-using-terraform-556a</link>
      <guid>https://dev.to/bipin_ghimire_4b4cabb807c/a-comprehensive-guide-to-infrastructure-as-code-iac-using-terraform-556a</guid>
      <description>&lt;p&gt;➡️ An open-source Infrastructure as Code (IaC) program called Terraform enables declarative cloud infrastructure definition, provisioning, and management. You can follow this instructions to set up Terraform step-by-step.🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftdshoy9875fo20jabt4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftdshoy9875fo20jabt4m.png" alt="Image description" width="800" height="395"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step One&lt;/strong&gt;: Install the terraform &lt;br&gt;
 In linux/ Mac:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

sudo apt update &amp;amp;&amp;amp; sudo apt install terraform

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confirm the installation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Create a Terraform Project&lt;br&gt;
Create a project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir terraform-aws &amp;amp;&amp;amp; cd terraform-aws
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize a new Terraform project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Write Your First Terraform Configuration&lt;/p&gt;

&lt;p&gt;Terraform configures itself using.tf files. An example main.tf file for setting up an AWS EC2 instance may be found below:&lt;/p&gt;

&lt;p&gt;Create main.tf&lt;br&gt;
 &lt;strong&gt;Step 4:&lt;/strong&gt; Initial Terraform&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;provider "aws" {
  region = "us-east-1"
}

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0" # Change based on your region
  instance_type = "t2.micro"

  tags = {
    Name = "TerraformInstance"
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To download provider plugins and initialize Terraform, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Plan Infrastructure&lt;/p&gt;

&lt;p&gt;Check what changes Terraform will make:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform plan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Apply Configuration&lt;br&gt;
Provision the resources:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform apply -auto-approve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AWS EC2 instance will be created as a result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7:&lt;/strong&gt; Destroy Infrastructure&lt;/p&gt;

&lt;p&gt;To delete resources created by Terraform:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform destroy -auto-approve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have successfully used Terraform to install infrastructure!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
