<?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: vaibhavlokhande3000</title>
    <description>The latest articles on DEV Community by vaibhavlokhande3000 (@ironmanav3000).</description>
    <link>https://dev.to/ironmanav3000</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%2F779803%2F92ee420a-2052-41eb-a21e-4274c621e2e5.jpg</url>
      <title>DEV Community: vaibhavlokhande3000</title>
      <link>https://dev.to/ironmanav3000</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ironmanav3000"/>
    <language>en</language>
    <item>
      <title>Why Pull Base Images When You Can Build Your Own?</title>
      <dc:creator>vaibhavlokhande3000</dc:creator>
      <pubDate>Sat, 14 Dec 2024 13:11:39 +0000</pubDate>
      <link>https://dev.to/ironmanav3000/why-pull-base-images-when-you-can-build-your-own-22ml</link>
      <guid>https://dev.to/ironmanav3000/why-pull-base-images-when-you-can-build-your-own-22ml</guid>
      <description>&lt;p&gt;Ever wondered why you’re pulling base images like everyone else when you could just… make your own? Revolutionary idea, right?&lt;/p&gt;

&lt;p&gt;No more relying on pre-made images, no more "is this secure?" overthinking - it’s time to roll up your sleeves and DIY your container base. And guess what? It’s easier than you think. Let me take you through the process with this simple, step-by-step guide.&lt;/p&gt;

&lt;p&gt;(Spoiler: it’ll feel like cooking your own pizza from scratch instead of ordering one online. Bonus satisfaction guaranteed.)&lt;/p&gt;




&lt;p&gt;🛠️ What You Need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Buildah: Your go-to container-building tool.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ubuntu AMI Server: A clean slate to start with.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Debootstrap: For creating your Ubuntu filesystem.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Container Registry: To store your shiny new creation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Before diving in, let’s break down Buildah and Debootstrap—the dynamic duo of this process:&lt;/p&gt;

&lt;p&gt;🔹 Buildah: A powerful command-line tool for building, modifying, and managing container images, independent of a container runtime. It gives you more flexibility and control.&lt;/p&gt;

&lt;p&gt;🔹 Debootstrap: A utility that helps you create a minimal Ubuntu/Debian filesystem, perfect for a lightweight and clean base image.&lt;/p&gt;

&lt;p&gt;Together, these tools make building custom container images efficient and streamlined. 🚀&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;📋 Steps to Create Your Base Image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Lets set up our machine first:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
For this guide, I’m using an AWS EC2 instance with the Ubuntu AMI.&lt;/p&gt;

&lt;p&gt;First, update your machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo -i
apt update 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;2. Installing requirements:&lt;/strong&gt;&lt;br&gt;
Installing Buildah:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt install buildah
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Installing debootstrap:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; apt install debootstrap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;3. Launching an empty container:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s spin up a completely empty container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;buildah from scratch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Container running successfully:&lt;br&gt;
(This is an empty container)&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%2Fovf5diqb6qw3cmivddvm.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%2Fovf5diqb6qw3cmivddvm.png" alt="Image description" width="744" height="133"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat /etc/os-release #Check version of your ubuntu os 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mine noble here&lt;br&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%2F9udhr5nfxwxnk093fq7c.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%2F9udhr5nfxwxnk093fq7c.png" alt="Image description" width="744" height="265"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;4. Mount the container filesystem&lt;/strong&gt;&lt;br&gt;
 We need to access the container like a regular directory. Use the command below to mount the filesystem and store the mount point in &lt;code&gt;scratchmnt&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scratchmnt=$(buildah mount working-container) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;5. Creating Ubuntu filesystem in the container directory&lt;/strong&gt;&lt;br&gt;
Here comes the fun part—use Debootstrap to create a minimal Ubuntu ‘Noble’ filesystem inside the mounted container directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;debootstrap noble $scratchmnt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once that's done, you’ll see all the OS files magically appear in the container!&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%2Flayy6itql2x7jhr2t9qo.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%2Flayy6itql2x7jhr2t9qo.png" alt="Image description" width="664" height="914"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;6. Building an image from container:&lt;/strong&gt;&lt;br&gt;
Now let’s commit your work and package it as a custom image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; buildah commit working-container vaibhavs_ubuntu_base_image:0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F23h6esap56xpefw05pw9.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%2F23h6esap56xpefw05pw9.png" alt="Image description" width="744" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boom! You’ve successfully built your very own Ubuntu image 🎉—give yourself a high-five, you genius! &lt;/p&gt;

&lt;p&gt;Check your images:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;buildah images    #list images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Frin9lmq2wgnvrcc16l1y.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%2Frin9lmq2wgnvrcc16l1y.png" alt="Image description" width="744" height="77"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Time to show off your masterpiece—let’s push that image to the repo and make it official! 🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here are some best options to show off:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html" rel="noopener noreferrer"&gt;AWS Amazon Container Registry(ECR) &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/reference/cli/docker/image/push/" rel="noopener noreferrer"&gt;Dockerhub Registry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.quay.io/solution/getting-started.html" rel="noopener noreferrer"&gt;Quay.io Registry&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Pull My Image and Get Started&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can grab my image from here—go ahead, it’s all yours!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull quay.io/vlokhande3000/ubuntu_image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F1azjpfbmjox84c9ztn2y.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%2F1azjpfbmjox84c9ztn2y.png" alt="Image description" width="744" height="176"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;And there you have it—your very own custom Ubuntu base image!&lt;/p&gt;




&lt;h1&gt;
  
  
  Benefits of Building Your Own Container Base Image
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Greater Control&lt;/strong&gt;&lt;br&gt;
By building your own base image, you have full control over the environment. You can ensure that only the software and dependencies you need are included, making it more lightweight and secure compared to relying on pre-made images.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enhanced Security&lt;/strong&gt;&lt;br&gt;
Custom base images allow you to eliminate unnecessary components and reduce the attack surface. You can ensure the image is up-to-date and free of vulnerabilities by manually installing and configuring only trusted software.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tailored Environment&lt;/strong&gt;&lt;br&gt;
You can create a container with exactly the configurations, tools, and libraries you need, optimizing it for your specific use case. This results in a more efficient and purpose-built image compared to a generic one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No Dependency on External Images&lt;/strong&gt;&lt;br&gt;
By avoiding pre-built images, you eliminate the need to trust external sources. You can be confident that your image is built exactly the way you want, and there’s no risk of pulling a vulnerable or outdated base image from public repositories.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved Performance&lt;/strong&gt;&lt;br&gt;
Custom base images can be optimized to minimize the size of the container, reducing overhead. This helps improve the performance of your containerized applications, as smaller images take less time to pull and deploy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexibility for Future Modifications&lt;/strong&gt;&lt;br&gt;
Once you have created your custom base image, you can easily modify it in the future to include additional software, configuration changes, or security updates. It also gives you the flexibility to scale and adapt as your projects evolve.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Satisfaction of Creating from Scratch&lt;/strong&gt;&lt;br&gt;
Just like cooking your own pizza 🍕, there's something incredibly satisfying about creating a custom container base image from scratch, knowing it’s optimized and built exactly the way you want it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Thanks!!
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/vaibhav-lokhande-216710219/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>kubernetes</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Terraform - Creating EC2 instances</title>
      <dc:creator>vaibhavlokhande3000</dc:creator>
      <pubDate>Wed, 06 Nov 2024 11:20:55 +0000</pubDate>
      <link>https://dev.to/ironmanav3000/terraform-creating-ec2-instances-2gk9</link>
      <guid>https://dev.to/ironmanav3000/terraform-creating-ec2-instances-2gk9</guid>
      <description>&lt;h2&gt;
  
  
  Automating EC2 Instance Creation with Terraform
&lt;/h2&gt;

&lt;p&gt;Hey, devs! Don’t worry you're at the right place! 😉&lt;/p&gt;

&lt;p&gt;If you’ve ever had to create multiple EC2 instances through the AWS dashboard, you know it can be a time-consuming process. But there’s a smarter way: Infrastructure as Code (IaC) using Terraform! With Terraform, we can automate the creation and management of AWS resources, including EC2 instances, making our infrastructure repeatable and manageable with just a few commands. Let me walk you through the setup!&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠 Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into Terraform, make sure you have:&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;AWS CLI Configured&lt;/strong&gt;: The AWS CLI should be set up and configured on your machine with the necessary permissions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws configure #configuring aws account 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter your access keys and secret access keys when prompted, and you’re good to go!&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%2Fdgakb46vusisikp6789s.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%2Fdgakb46vusisikp6789s.png" alt="Image description" width="800" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Terraform Installed&lt;/strong&gt;: Ensure Terraform is installed. &lt;br&gt;
&lt;a href="https://developer.hashicorp.com/terraform/install" rel="noopener noreferrer"&gt;Terraform Documentation&lt;/a&gt;&lt;br&gt;
Once these are ready, you’re all set for automation! &lt;/p&gt;
&lt;h2&gt;
  
  
  Setting Up Your Terraform Project:
&lt;/h2&gt;

&lt;p&gt;First, create a new directory for your Terraform project, which will house all the necessary configuration files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
mkdir ec2_gen #making a directory
cd ec2_gen    

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

&lt;/div&gt;



&lt;p&gt;Inside this directory, we’ll create a Terraform configuration file that defines our EC2 instances.&lt;/p&gt;

&lt;h2&gt;
  
  
  📝 Writing the Terraform Configuration
&lt;/h2&gt;

&lt;p&gt;Use a text editor to create the main.tf file. Here, we’ll define our AWS provider, configure the region, and specify the resource (EC2 instances) we want to create.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vim main.tf

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

&lt;/div&gt;



&lt;p&gt;Now, add the following configuration to main.tf:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Specifies Terraform block with required providers and versions
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"      # Specifies the source for the AWS provider
      version = "~&amp;gt; 4.16"            # Version constraint for the AWS provider
    }
  }
  required_version = "&amp;gt;= 1.9.8"      # Minimum Terraform version required
}

# Configures the AWS provider with a specific region
provider "aws" {
  region = "ap-south-1"              # AWS region (e.g., ap-south-1 for Asia Pacific, Mumbai)
}

# Defines an EC2 instance resource
resource "aws_instance" "my_ec2_instance" {
  ami           = "ami-04a37924ffe27da53"  # Amazon Linux 2 AMI ID (adjust to your region)
  instance_type = "t2.micro"               # Instance type (e.g., t2.micro)
  count         = 2                        # Number of instances to create (2 in this case)

  # Tags help to identify and manage resources
  tags = {
    Name = "terraform-instance-${count.index + 1}"  # Tag instances with unique names
  }
}

# Outputs the public IPs of the created EC2 instances
output "ec2_public_ips" {
  value = aws_instance.my_ec2_instance[*].public_ip  # Outputs the public IP addresses as a list
}

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

&lt;/div&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%2Fdvjbq8sm85cieuhy3fnn.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%2Fdvjbq8sm85cieuhy3fnn.png" alt="Image description" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🔍 Explanation of the Code
&lt;/h2&gt;

&lt;p&gt;Provider Block: This block specifies the AWS provider details, including the region. Make sure to adjust the region if you’re working outside of ap-south-1.&lt;br&gt;
Resource Block: Here, we define the aws_instance resource. The count parameter lets us create multiple instances—in this case, 2 EC2 instances.&lt;br&gt;
Tags: We use tags to help identify instances. The name will appear as "example-instance-1," "example-instance-2," and so on.&lt;br&gt;
Output Block: This block outputs the public IPs of our newly created EC2 instances, which can be useful for further automation or SSH access.&lt;/p&gt;
&lt;h2&gt;
  
  
  Running the Terraform Code
&lt;/h2&gt;

&lt;p&gt;With the configuration complete, let’s initialize and apply it. Here’s the sequence of commands you need to run:&lt;/p&gt;

&lt;p&gt;Initialize Terraform: Sets up the working directory and downloads the necessary provider plugins.&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;Validate the Configuration: Checks for syntax errors or misconfigurations.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2Fak1vachmazx7hhfr7l84.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%2Fak1vachmazx7hhfr7l84.png" alt="Image description" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Plan the Deployment: Shows what Terraform will do without making any actual changes. This is a great way to confirm before deploying.&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;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%2Fnxa2n6nie7odqoulhsrm.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%2Fnxa2n6nie7odqoulhsrm.png" alt="Image description" width="800" height="454"&gt;&lt;/a&gt;&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%2Fyart8ly5v319h9d84z6f.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%2Fyart8ly5v319h9d84z6f.png" alt="Image description" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Apply the Changes: Creates the resources defined in main.tf.&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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fa2a048kpync28qdw2lqw.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%2Fa2a048kpync28qdw2lqw.png" alt="Image description" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During the apply step, Terraform will prompt you to confirm. Type yes to proceed.&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%2F10tiyqaxlx8z56efmquz.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%2F10tiyqaxlx8z56efmquz.png" alt="Image description" width="800" height="324"&gt;&lt;/a&gt;&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%2Fo3n08xaotw12vi24i71t.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%2Fo3n08xaotw12vi24i71t.png" alt="Image description" width="800" height="322"&gt;&lt;/a&gt;&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%2Fa50mk8s8apxezmjaokpn.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%2Fa50mk8s8apxezmjaokpn.png" alt="Image description" width="800" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🎉 Verify the Results&lt;br&gt;
Head over to the AWS dashboard and check your EC2 instances. You should see the instances created with the specified tags and configurations. 🚀&lt;/p&gt;

&lt;p&gt;wait wait wait...&lt;br&gt;
Created hundreds instances just for fun and don't know how to terminate them? &lt;br&gt;
Don't just do it manually, haha!!&lt;/p&gt;

&lt;p&gt;Don’t worry! Just use:&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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will remove all resources defined in your configuration. Thank me later! 😉&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus tip&lt;/strong&gt;&lt;br&gt;
You can choose Amazon Machine Image by changing AMI ID in the code.&lt;/p&gt;

&lt;p&gt;Follow on &lt;a href="https://www.linkedin.com/in/vaibhav-lokhande-216710219/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>automation</category>
      <category>devops</category>
      <category>terraform</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
