<?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>Forem: Abishek Haththakage</title>
    <description>The latest articles on Forem by Abishek Haththakage (@abhixsh).</description>
    <link>https://forem.com/abhixsh</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%2F997910%2Fb1d439e3-1bc9-4a1f-98b8-27594c16e025.jpeg</url>
      <title>Forem: Abishek Haththakage</title>
      <link>https://forem.com/abhixsh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/abhixsh"/>
    <language>en</language>
    <item>
      <title>Terraform Isn’t What I Expected: Hidden Things You Should Know</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Fri, 27 Mar 2026 07:52:16 +0000</pubDate>
      <link>https://forem.com/abhixsh/terraform-isnt-what-i-expected-hidden-things-you-should-know-26bl</link>
      <guid>https://forem.com/abhixsh/terraform-isnt-what-i-expected-hidden-things-you-should-know-26bl</guid>
      <description>&lt;p&gt;Terraform is an &lt;strong&gt;Infrastructure as Code (IaC)&lt;/strong&gt; tool made by HashiCorp. Instead of clicking around in the AWS or Azure console to create servers, databases, and networks, you write code that describes the infrastructure you want, and Terraform makes it happen. Automatically. Repeatably. Safely.&lt;/p&gt;

&lt;p&gt;When I started learning Terraform, I came across a lot of interesting and unexpected things that aren’t usually explained in most tutorials.&lt;/p&gt;

&lt;p&gt;Most guides focus on the basics, how to create resources, run plan, and apply changes. But as I went deeper, I found concepts and behaviors that really changed how I understand and use Terraform.&lt;/p&gt;

&lt;p&gt;So in this post, I’m sharing those less obvious but important things I learned along the way, the kind of knowledge that actually makes you more confident using Terraform in real-world scenarios.&lt;/p&gt;

&lt;p&gt;Let's dive in.&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%2Fzbgioi4ls9ca4w2hs8az.gif" 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%2Fzbgioi4ls9ca4w2hs8az.gif" alt=" " width="400" height="300"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Implicit vs Explicit Dependencies
&lt;/h2&gt;

&lt;p&gt;When Terraform creates infrastructure, it needs to know the right &lt;em&gt;order&lt;/em&gt; to create things. You can't create a subnet before the VPC it belongs to, for example. Terraform handles this through &lt;strong&gt;dependencies&lt;/strong&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%2Fz3roiwll1qv38tx5gc5e.jpeg" 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%2Fz3roiwll1qv38tx5gc5e.jpeg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implicit Dependencies (The Automatic Way)
&lt;/h3&gt;

&lt;p&gt;When one resource references an attribute of another, Terraform automatically figures out the order. You don't need to write anything extra.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_vpc"&lt;/span&gt; &lt;span class="s2"&gt;"main"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;cidr_block&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"10.0.0.0/16"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_subnet"&lt;/span&gt; &lt;span class="s2"&gt;"subnet1"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;vpc_id&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_vpc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;   &lt;span class="c1"&gt;# This reference tells Terraform: VPC first!&lt;/span&gt;
  &lt;span class="nx"&gt;cidr_block&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"10.0.1.0/24"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Terraform sees that &lt;code&gt;subnet1&lt;/code&gt; needs &lt;code&gt;aws_vpc.main.id&lt;/code&gt;, so it automatically creates the VPC before the subnet. Clean, simple, and the preferred approach.&lt;/p&gt;

&lt;h3&gt;
  
  
  Explicit Dependencies (The Manual Way)
&lt;/h3&gt;

&lt;p&gt;Sometimes there's no direct attribute reference between resources, but you still need one to be created before the other. In that case, use &lt;code&gt;depends_on&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"app"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;

  &lt;span class="nx"&gt;depends_on&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;aws_security_group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sg&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_security_group"&lt;/span&gt; &lt;span class="s2"&gt;"sg"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"app-sg"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though the instance doesn't reference the security group directly, &lt;code&gt;depends_on&lt;/code&gt; forces Terraform to create the security group first.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Implicit&lt;/th&gt;
&lt;th&gt;Explicit&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Automatic&lt;/td&gt;
&lt;td&gt;Manual (&lt;code&gt;depends_on&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;When to use&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Most of the time&lt;/td&gt;
&lt;td&gt;Hidden or indirect dependency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Recommended&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Only when needed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Simple Rule:&lt;/strong&gt; If Terraform can detect the relationship → use implicit. If it can't → use &lt;code&gt;depends_on&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  2. Managing State with terraform state
&lt;/h2&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%2F953qi9vm04bk2yjk2evz.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%2F953qi9vm04bk2yjk2evz.png" alt=" " width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Terraform keeps a &lt;strong&gt;state file&lt;/strong&gt; that tracks all the infrastructure it manages. The &lt;code&gt;terraform state&lt;/code&gt; command lets you inspect and manipulate this file.&lt;/p&gt;

&lt;p&gt;Here are the subcommands you'll use most often:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# See everything Terraform is currently managing&lt;/span&gt;
terraform state list

&lt;span class="c"&gt;# Inspect detailed attributes of one resource&lt;/span&gt;
terraform state show aws_instance.my_ec2

&lt;span class="c"&gt;# Rename a resource without recreating it (useful when refactoring code)&lt;/span&gt;
terraform state &lt;span class="nb"&gt;mv &lt;/span&gt;aws_instance.old aws_instance.new

&lt;span class="c"&gt;# Stop Terraform from managing a resource (the real resource still exists!)&lt;/span&gt;
terraform state &lt;span class="nb"&gt;rm &lt;/span&gt;aws_instance.my_ec2

&lt;span class="c"&gt;# Download the raw state file (useful for backups)&lt;/span&gt;
terraform state pull

&lt;span class="c"&gt;# Upload a state file (use with extreme caution)&lt;/span&gt;
terraform state push terraform.tfstate

&lt;span class="c"&gt;# Change provider references inside state&lt;/span&gt;
terraform state replace-provider &lt;span class="se"&gt;\&lt;/span&gt;
  registry.terraform.io/hashicorp/aws &lt;span class="se"&gt;\&lt;/span&gt;
  registry.terraform.io/custom/aws
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;What It Does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Show all tracked resources&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;show&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inspect one resource in detail&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mv&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Rename/move without recreating&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Remove from state (cloud resource stays!)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pull&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Download state JSON&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;push&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Upload state (risky — overwrites!)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;replace-provider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Swap provider namespace&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Always back up your state file before making manual changes.&lt;/strong&gt; A corrupted state file is one of the worst things that can happen to a Terraform project.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  3. Heredoc Syntax
&lt;/h2&gt;

&lt;p&gt;Sometimes you need to pass a multi-line string into a resource — like a shell script for an EC2 instance's startup commands, or a JSON config block. That's where &lt;strong&gt;heredoc syntax&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Heredoc
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"example"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;user_data&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
#!/bin/bash
echo "Hello, World"
apt update
apt install -y nginx
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything between &lt;code&gt;&amp;lt;&amp;lt;EOF&lt;/code&gt; and &lt;code&gt;EOF&lt;/code&gt; is treated as a single string.&lt;/p&gt;

&lt;h3&gt;
  
  
  Indented Heredoc (Recommended)
&lt;/h3&gt;

&lt;p&gt;Using &lt;code&gt;&amp;lt;&amp;lt;-EOF&lt;/code&gt; (note the dash) lets you indent the content for cleaner, more readable code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"example"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;user_data&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;-&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
    #!/bin/bash
    echo "Cleaner indentation"
    apt update
&lt;/span&gt;&lt;span class="no"&gt;  EOF
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&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%2F3zoxdy1shs2yt3ky80rj.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%2F3zoxdy1shs2yt3ky80rj.png" alt=" " width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  With Variable Interpolation
&lt;/h3&gt;

&lt;p&gt;You can use Terraform variables inside a heredoc:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"app_name"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"MyApp"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="s2"&gt;"welcome_message"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;-&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
    Hello from ${var.app_name}
    Terraform is managing this infrastructure.
&lt;/span&gt;&lt;span class="no"&gt;  EOF
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Tips:&lt;/strong&gt; The closing delimiter must be on its own line with no trailing spaces. Use &lt;code&gt;&amp;lt;&amp;lt;-EOF&lt;/code&gt; whenever you can — it keeps your code visually clean.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. Provisioners
&lt;/h2&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%2Ffxcgbmz3fjyh1917segd.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%2Ffxcgbmz3fjyh1917segd.png" alt=" " width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Provisioners let you run scripts or commands on a resource &lt;strong&gt;after it's created&lt;/strong&gt; (or before it's destroyed). Think of them as a way to do last-mile setup that Terraform's declarative model doesn't cover.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Important:&lt;/strong&gt; Terraform itself recommends treating provisioners as a &lt;strong&gt;last resort&lt;/strong&gt;. Prefer native options like &lt;code&gt;user_data&lt;/code&gt;, cloud-init, or configuration management tools like Ansible whenever possible.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  local-exec — Runs on Your Machine
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"example"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;

  &lt;span class="nx"&gt;provisioner&lt;/span&gt; &lt;span class="s2"&gt;"local-exec"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;command&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"echo 'Instance created at ${self.public_ip}'"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this to trigger local scripts, send notifications, or log events.&lt;/p&gt;

&lt;h3&gt;
  
  
  remote-exec — Runs Inside the Resource
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"example"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;

  &lt;span class="nx"&gt;connection&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ssh"&lt;/span&gt;
    &lt;span class="nx"&gt;user&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ubuntu"&lt;/span&gt;
    &lt;span class="nx"&gt;private_key&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"key.pem"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;host&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;public_ip&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;provisioner&lt;/span&gt; &lt;span class="s2"&gt;"remote-exec"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;inline&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="s2"&gt;"sudo apt update"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"sudo apt install -y nginx"&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  file — Copies Files to the Resource
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;provisioner&lt;/span&gt; &lt;span class="s2"&gt;"file"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;source&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"app.conf"&lt;/span&gt;
  &lt;span class="nx"&gt;destination&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/tmp/app.conf"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Destroy-Time Provisioner
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;provisioner&lt;/span&gt; &lt;span class="s2"&gt;"local-exec"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;when&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;destroy&lt;/span&gt;
  &lt;span class="nx"&gt;command&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"echo 'Cleaning up before destroy'"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provisioner&lt;/th&gt;
&lt;th&gt;Runs Where&lt;/th&gt;
&lt;th&gt;Common Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;local-exec&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Your local machine&lt;/td&gt;
&lt;td&gt;Notifications, logging, local scripts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;remote-exec&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inside the created resource&lt;/td&gt;
&lt;td&gt;Package installs, service config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Local → Remote&lt;/td&gt;
&lt;td&gt;Upload config files or scripts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  5. Provisioner Behavior
&lt;/h2&gt;

&lt;p&gt;Understanding &lt;em&gt;when&lt;/em&gt; and &lt;em&gt;how&lt;/em&gt; provisioners run is important — especially because they can behave in surprising ways.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;They only run on creation (or recreation), not every apply.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you change a tag on an EC2 instance, Terraform updates the tag — but it does &lt;em&gt;not&lt;/em&gt; re-run any provisioners. Provisioners only re-run if the resource is destroyed and recreated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;They run in order.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you define multiple provisioners on one resource, they execute sequentially from top to bottom.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Failure stops everything by default.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;provisioner&lt;/span&gt; &lt;span class="s2"&gt;"remote-exec"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;inline&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"exit 1"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="nx"&gt;on_failure&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;continue&lt;/span&gt;   &lt;span class="c1"&gt;# use "continue" to ignore errors, "fail" to stop (default)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;They are NOT tracked in state.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Terraform records that a resource exists, but it has no idea what your provisioner actually changed inside that resource. This makes provisioners hard to reason about over time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key insight:&lt;/strong&gt; Provisioners break Terraform's clean declarative model. The more you rely on them, the harder your infrastructure becomes to maintain and reproduce.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  6. Taint and Replace
&lt;/h2&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%2F6a1qott982yjpuxwxwy0.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%2F6a1qott982yjpuxwxwy0.png" alt=" " width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes a resource ends up in a bad state — a provisioner failed midway through, someone manually changed it, or it's just broken. You need to force Terraform to destroy and recreate it.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Old Way: terraform taint (Deprecated)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform taint aws_instance.my_ec2   &lt;span class="c"&gt;# Mark as "needs replacement"&lt;/span&gt;
terraform apply                       &lt;span class="c"&gt;# Destroys + recreates on next apply&lt;/span&gt;

terraform untaint aws_instance.my_ec2 &lt;span class="c"&gt;# Change your mind? Undo it.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Modern Way: -replace Flag (Recommended)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform apply &lt;span class="nt"&gt;-replace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"aws_instance.my_ec2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This does the same thing — destroys and recreates — but in a single step, with no intermediate state change. It's cleaner and less error-prone.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;taint&lt;/code&gt; (legacy)&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;-replace&lt;/code&gt; (modern)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Steps&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2 (taint + apply)&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Recommended&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ Recreating a resource causes downtime. Always run &lt;code&gt;terraform plan&lt;/code&gt; first to understand the full impact before applying.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  7. Debugging Terraform
&lt;/h2&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%2Fw8ovekm8migkqty9oltb.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%2Fw8ovekm8migkqty9oltb.png" alt=" " width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When things go wrong (and they will), here's how to figure out what's happening.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enable Detailed Logs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;TF_LOG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;DEBUG
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;TF_LOG_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;terraform.log
terraform apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Log levels from least to most verbose: &lt;code&gt;ERROR&lt;/code&gt; → &lt;code&gt;WARN&lt;/code&gt; → &lt;code&gt;INFO&lt;/code&gt; → &lt;code&gt;DEBUG&lt;/code&gt; → &lt;code&gt;TRACE&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;DEBUG&lt;/code&gt; for most issues. Only reach for &lt;code&gt;TRACE&lt;/code&gt; when you're really stuck — it's extremely noisy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Your Standard Debug Toolkit
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform validate          &lt;span class="c"&gt;# Check for syntax errors&lt;/span&gt;
terraform &lt;span class="nb"&gt;fmt&lt;/span&gt;               &lt;span class="c"&gt;# Auto-fix formatting (easier to spot mistakes)&lt;/span&gt;
terraform plan              &lt;span class="c"&gt;# See what Terraform wants to do&lt;/span&gt;
terraform state list        &lt;span class="c"&gt;# What is Terraform managing?&lt;/span&gt;
terraform state show &amp;lt;resource&amp;gt;  &lt;span class="c"&gt;# What are the actual values?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Interactive Console
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform console
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This opens a REPL where you can test expressions interactively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;
&lt;span class="s2"&gt;"production"&lt;/span&gt;
&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subnet_ids&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;aws_instance&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;web&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;public_ip&lt;/span&gt;
&lt;span class="s2"&gt;"54.23.11.100"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's incredibly useful for debugging variables, expressions, and outputs without running a full apply.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Debug Reference
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Where to Look&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Resource not created&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;terraform plan&lt;/code&gt; + check dependencies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong values&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;terraform console&lt;/code&gt; + check variable definitions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Provisioner fails&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;TF_LOG=DEBUG&lt;/code&gt; + check SSH connection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unexpected changes&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;terraform state show&lt;/code&gt; vs real infra&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Provider errors&lt;/td&gt;
&lt;td&gt;Check authentication and permissions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Never commit your debug log files — they may contain API keys and other secrets.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  8. Importing Existing Infrastructure
&lt;/h2&gt;

&lt;p&gt;You've probably inherited some infrastructure that was created manually — either by clicking around in the AWS console or by a script. &lt;code&gt;terraform import&lt;/code&gt; lets you bring that existing infrastructure under Terraform's management.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Import only adds the resource to Terraform's state. It does NOT generate &lt;code&gt;.tf&lt;/code&gt; code for you, and it doesn't touch the real infrastructure.&lt;/p&gt;
&lt;/blockquote&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%2Fkopkinxhpjmgr064cljx.webp" 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%2Fkopkinxhpjmgr064cljx.webp" alt=" " width="800" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Classic Import Workflow
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Step 1: Write the resource config in your .tf file&lt;/span&gt;
resource &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"my_ec2"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  ami           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-xxxx"&lt;/span&gt;
  instance_type &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Step 2: Import the real resource into state&lt;/span&gt;
terraform import aws_instance.my_ec2 i-1234567890abcdef0

&lt;span class="c"&gt;# Step 3: Run plan — you'll probably see differences&lt;/span&gt;
terraform plan
&lt;span class="c"&gt;# Update your .tf config to match until plan shows no changes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Modern Way: Import Blocks (Terraform 1.5+)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;my_ec2&lt;/span&gt;
  &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"i-1234567890abcdef0"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then just run &lt;code&gt;terraform apply&lt;/code&gt;. This approach is declarative, version-controlled, and much cleaner.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Classic Import&lt;/th&gt;
&lt;th&gt;Import Block (1.5+)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Declarative&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Version controlled&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Recommended&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;For older setups&lt;/td&gt;
&lt;td&gt;Preferred&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  9. Modules
&lt;/h2&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%2Fzohw04d9ctx10egjirpy.jpg" 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%2Fzohw04d9ctx10egjirpy.jpg" alt=" " width="800" height="696"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As your infrastructure grows, putting everything in one giant &lt;code&gt;main.tf&lt;/code&gt; file becomes unmanageable. &lt;strong&gt;Modules&lt;/strong&gt; are Terraform's solution — they let you organize, reuse, and share infrastructure code.&lt;/p&gt;

&lt;p&gt;Think of a module like a function: it takes inputs (variables), does some work (creates resources), and returns outputs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Module Directory Structure
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;modules/
└── webserver/
    ├── main.tf        # The actual resources
    ├── variables.tf   # Input variables
    └── outputs.tf     # Values exposed to the caller
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Defining a Module
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# modules/webserver/variables.tf&lt;/span&gt;
&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"instance_type"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"ami"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# modules/webserver/main.tf&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance_type&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ami&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# modules/webserver/outputs.tf&lt;/span&gt;
&lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="s2"&gt;"public_ip"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;web&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;public_ip&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Calling a Module
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# root main.tf&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;source&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"./modules/webserver"&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Use the module's output&lt;/span&gt;
&lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="s2"&gt;"server_ip"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;web&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;public_ip&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Module Sources
&lt;/h3&gt;

&lt;p&gt;Modules can come from anywhere:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Local folder&lt;/span&gt;
&lt;span class="nx"&gt;source&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"./modules/webserver"&lt;/span&gt;

&lt;span class="c1"&gt;# Git repository&lt;/span&gt;
&lt;span class="nx"&gt;source&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"git::https://github.com/your-org/tf-modules.git//webserver"&lt;/span&gt;

&lt;span class="c1"&gt;# Terraform Registry (public or private)&lt;/span&gt;
&lt;span class="nx"&gt;source&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hashicorp/consul/aws"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Best Practice:&lt;/strong&gt; Keep modules small and focused on a single concern. Use variables for flexibility and outputs to expose only what callers need.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  10. plan --refresh=false
&lt;/h2&gt;

&lt;p&gt;By default, when you run &lt;code&gt;terraform plan&lt;/code&gt;, Terraform does two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Refresh&lt;/strong&gt; — queries your cloud provider (AWS, Azure, etc.) to get the current real state of all resources&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compare&lt;/strong&gt; — checks that against your code and state file, then shows what needs to change&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;code&gt;--refresh=false&lt;/code&gt; flag skips step 1. Terraform works only from its cached state file, without making any API calls to check live infrastructure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform plan                  &lt;span class="c"&gt;# Default: queries live infra&lt;/span&gt;
terraform plan &lt;span class="nt"&gt;--refresh&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;  &lt;span class="c"&gt;# Faster: uses cached state only&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When is this useful?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In CI/CD pipelines where speed matters and you're confident the state matches reality&lt;/li&gt;
&lt;li&gt;When cloud API calls are slow or rate-limited&lt;/li&gt;
&lt;li&gt;When you're iterating quickly on code changes and don't need drift detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When is it risky?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If someone has made manual changes outside Terraform, you won't detect them&lt;/li&gt;
&lt;li&gt;The apply could produce unexpected results if the cached state is stale&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 For day-to-day manual runs, always keep refresh enabled. Use &lt;code&gt;--refresh=false&lt;/code&gt; only in controlled environments.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  11. The file() Function
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;file()&lt;/code&gt; function reads a local file and returns its contents as a string. It's one of the most commonly used functions in real Terraform projects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Pass a shell script to an EC2 instance's startup commands&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
  &lt;span class="nx"&gt;user_data&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"scripts/setup.sh"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Upload a config file to S3&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_s3_object"&lt;/span&gt; &lt;span class="s2"&gt;"config"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;bucket&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_s3_bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;my_bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
  &lt;span class="nx"&gt;key&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"app.conf"&lt;/span&gt;
  &lt;span class="nx"&gt;content&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"config/app.conf"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need &lt;strong&gt;dynamic&lt;/strong&gt; content — where parts of the file change based on variables — use &lt;code&gt;templatefile()&lt;/code&gt; instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;user_data&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;templatefile&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"scripts/setup.sh.tpl"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;app_name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app_name&lt;/span&gt;
  &lt;span class="nx"&gt;port&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Use When&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;file()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Static file&lt;/td&gt;
&lt;td&gt;Content never changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;templatefile()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;File + variables map&lt;/td&gt;
&lt;td&gt;Content has dynamic parts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  12. Built-in Functions
&lt;/h2&gt;

&lt;p&gt;Terraform includes a rich set of built-in functions for manipulating values. Here's a practical overview of each category.&lt;/p&gt;

&lt;h3&gt;
  
  
  Numeric Functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;abs&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;-5&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;# → 5     (absolute value)&lt;/span&gt;
&lt;span class="nx"&gt;ceil&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;2.3&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# → 3     (round up)&lt;/span&gt;
&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;2.7&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# → 2     (round down)&lt;/span&gt;
&lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# → 7&lt;/span&gt;
&lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# → 2&lt;/span&gt;
&lt;span class="nx"&gt;pow&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# → 8     (2 to the power of 3)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  String Functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;upper&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hello"&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;              &lt;span class="c1"&gt;# → "HELLO"&lt;/span&gt;
&lt;span class="nx"&gt;lower&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"WORLD"&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;              &lt;span class="c1"&gt;# → "world"&lt;/span&gt;
&lt;span class="nx"&gt;trim&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"  hello  "&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;           &lt;span class="c1"&gt;# → "hello"&lt;/span&gt;
&lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"a-b-c"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"_"&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# → "a_b_c"&lt;/span&gt;
&lt;span class="nx"&gt;substr&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Terraform"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# → "Terra"&lt;/span&gt;
&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"-"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"c"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# → "a-b-c"&lt;/span&gt;
&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"-"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"a-b-c"&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;# → ["a", "b", "c"]&lt;/span&gt;
&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hello"&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;             &lt;span class="c1"&gt;# → 5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Collection Functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# → [1, 2, 3, 4]&lt;/span&gt;
&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;            &lt;span class="c1"&gt;# → 3&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"c"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# → "b"&lt;/span&gt;
&lt;span class="nx"&gt;contains&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# → true&lt;/span&gt;
&lt;span class="nx"&gt;distinct&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# → [1, 2, 3]&lt;/span&gt;
&lt;span class="nx"&gt;flatten&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# → [1, 2, 3, 4]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Map Functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;merge&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;# → {a = 1, b = 2}&lt;/span&gt;
&lt;span class="nx"&gt;lookup&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"b"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;# → 0 (returns default if key missing)&lt;/span&gt;
&lt;span class="nx"&gt;keys&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;           &lt;span class="c1"&gt;# → ["a", "b"]&lt;/span&gt;
&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;         &lt;span class="c1"&gt;# → [1, 2]&lt;/span&gt;
&lt;span class="nx"&gt;zipmap&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# → {a = 1, b = 2}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Type Conversion Functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;tostring&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# → "10"&lt;/span&gt;
&lt;span class="nx"&gt;tonumber&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"5"&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# → 5&lt;/span&gt;
&lt;span class="nx"&gt;tolist&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# → [1, 2]&lt;/span&gt;
&lt;span class="nx"&gt;tomap&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# → {a = 1}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Real-World Example Combining Functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"names"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"alice"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"bob"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"alice"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"carol"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="s2"&gt;"unique_upper_names"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="nx"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;distinct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# Result: ["ALICE", "BOB", "CAROL"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  13. Operators and Conditional Expressions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Arithmetic Operators
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;   &lt;span class="c1"&gt;# → 8&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="nx"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;   &lt;span class="c1"&gt;# → 2&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;   &lt;span class="c1"&gt;# → 15&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="err"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;  &lt;span class="c1"&gt;# → 5&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="err"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;  &lt;span class="c1"&gt;# → 1  (remainder)&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="err"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;  &lt;span class="c1"&gt;# → 8  (exponent)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Comparison Operators
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;   &lt;span class="c1"&gt;# → true&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="err"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;   &lt;span class="c1"&gt;# → true&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;    &lt;span class="c1"&gt;# → true&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;    &lt;span class="c1"&gt;# → true&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="err"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;   &lt;span class="c1"&gt;# → true&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;   &lt;span class="c1"&gt;# → true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Logical Operators
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="err"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;   &lt;span class="c1"&gt;# → false  (AND)&lt;/span&gt;
&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="err"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;   &lt;span class="c1"&gt;# → true   (OR)&lt;/span&gt;
&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;           &lt;span class="c1"&gt;# → false  (NOT)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Ternary (Conditional) Expression
&lt;/h3&gt;

&lt;p&gt;Terraform uses the same ternary pattern as many programming languages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;condition&lt;/span&gt; &lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;value_if_true&lt;/span&gt; &lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;value_if_false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"environment"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"prod"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="s2"&gt;"instance_type"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"prod"&lt;/span&gt; &lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"t2.large"&lt;/span&gt; &lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# prod → "t2.large", anything else → "t2.micro"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cleaner Pattern: Map Lookup
&lt;/h3&gt;

&lt;p&gt;For more than two options, nested ternaries get messy fast. A map lookup is far more readable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;locals&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;instance_sizes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;prod&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.large"&lt;/span&gt;
    &lt;span class="nx"&gt;stage&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.medium"&lt;/span&gt;
    &lt;span class="nx"&gt;dev&lt;/span&gt;   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="s2"&gt;"instance_type"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;local&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance_sizes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 Prefer map lookups over nested ternaries. They are easier to read, test, and extend when you add new environments.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  14. Workspaces
&lt;/h2&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%2F19lt7i4j800iucu2uddv.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%2F19lt7i4j800iucu2uddv.png" alt=" " width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Workspaces let you use a &lt;strong&gt;single Terraform configuration&lt;/strong&gt; to manage &lt;strong&gt;multiple separate environments&lt;/strong&gt; — each with its own isolated state file.&lt;/p&gt;

&lt;p&gt;Every Terraform project starts with one workspace called &lt;code&gt;default&lt;/code&gt;. You can create more as needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform workspace list              &lt;span class="c"&gt;# * default (the * shows current)&lt;/span&gt;
terraform workspace new dev           &lt;span class="c"&gt;# Create and switch to "dev"&lt;/span&gt;
terraform workspace &lt;span class="k"&gt;select &lt;/span&gt;staging    &lt;span class="c"&gt;# Switch to "staging"&lt;/span&gt;
terraform workspace show              &lt;span class="c"&gt;# Print current workspace name&lt;/span&gt;
terraform workspace delete dev        &lt;span class="c"&gt;# Delete (can't delete current)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Workspace Name in Resources
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_s3_bucket"&lt;/span&gt; &lt;span class="s2"&gt;"app"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;bucket&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"myapp-${terraform.workspace}-data"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the workspace is &lt;code&gt;dev&lt;/code&gt;, this creates &lt;code&gt;myapp-dev-data&lt;/code&gt;. When it's &lt;code&gt;prod&lt;/code&gt;, it creates &lt;code&gt;myapp-prod-data&lt;/code&gt;. Same code — separate, isolated infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  When to Use Workspaces (and When Not To)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Good fit:&lt;/strong&gt; Simple dev/staging/prod splits where all environments use almost the same config.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not a good fit:&lt;/strong&gt; Large, complex environments with significantly different configurations or many dependencies. For those, use separate directories with separate state backends.&lt;/p&gt;




&lt;h2&gt;
  
  
  15. Mutable vs Immutable Infrastructure
&lt;/h2&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%2Fptnao50vh3j5w9ej6mu5.webp" 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%2Fptnao50vh3j5w9ej6mu5.webp" alt=" " width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is one of the most important conceptual distinctions in modern DevOps.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mutable Infrastructure
&lt;/h3&gt;

&lt;p&gt;You create a server once, and then &lt;em&gt;change it in place&lt;/em&gt; over time — installing updates, patching software, modifying configs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Change instance_type → Terraform updates the existing instance&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.small"&lt;/span&gt;  &lt;span class="c1"&gt;# was t2.micro&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Faster individual updates, less resource churn.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; Over time, each server accumulates a unique history of changes. This is called &lt;strong&gt;configuration drift&lt;/strong&gt;, and it makes environments hard to reproduce and debug.&lt;/p&gt;

&lt;h3&gt;
  
  
  Immutable Infrastructure
&lt;/h3&gt;

&lt;p&gt;Instead of changing a server, you &lt;strong&gt;replace it entirely&lt;/strong&gt; with a new one built from a fresh image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Change AMI → Terraform destroys old instance, creates new one&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-new-version-456"&lt;/span&gt;  &lt;span class="c1"&gt;# was ami-old-version-123&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Environments are consistent and reproducible. Rollbacks are easy — just deploy the previous version. No drift.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; Requires automation maturity (image baking with Packer, CI/CD pipelines).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Simple way to remember:&lt;/strong&gt;&lt;br&gt;
Mutable → "Fix the server"&lt;br&gt;
Immutable → "Replace the server"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Modern DevOps strongly favors immutable infrastructure. Terraform makes this natural when combined with tools like Packer and Auto Scaling Groups.&lt;/p&gt;




&lt;h2&gt;
  
  
  16. Configuration Drift
&lt;/h2&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%2Fjjticmyiypx2q9w2t9k5.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%2Fjjticmyiypx2q9w2t9k5.png" alt=" " width="385" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Configuration drift is the gap between what your Terraform code &lt;em&gt;says&lt;/em&gt; your infrastructure should look like, and what it &lt;em&gt;actually&lt;/em&gt; looks like in the cloud.&lt;/p&gt;

&lt;p&gt;It happens when changes are made outside of Terraform:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Someone SSHes into a server and changes a config file&lt;/li&gt;
&lt;li&gt;A developer resizes an instance through the AWS console&lt;/li&gt;
&lt;li&gt;An automated script modifies a resource directly&lt;/li&gt;
&lt;li&gt;A hotfix is applied directly to production&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it's a problem:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Drift means your infrastructure is no longer reproducible. If you need to rebuild, you'll get something different from what's running. It also means bugs that only exist in drifted environments, which are notoriously hard to track down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Terraform detects it:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Terraform compares your code (desired state) against live infrastructure (actual state) and shows you the differences. Run this regularly — it's your drift detector.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to prevent it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use immutable infrastructure (replace, don't patch)&lt;/li&gt;
&lt;li&gt;Route all changes through Terraform and CI/CD — no manual console edits&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;terraform plan&lt;/code&gt; on a schedule to catch drift early&lt;/li&gt;
&lt;li&gt;Limit direct SSH access to servers&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  17. Lifecycle Rules
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;lifecycle&lt;/code&gt; block gives you control over how Terraform handles a resource's creation, update, and deletion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123"&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;

  &lt;span class="nx"&gt;lifecycle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;create_before_destroy&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="nx"&gt;prevent_destroy&lt;/span&gt;       &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="nx"&gt;ignore_changes&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="nx"&gt;replace_triggered_by&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;aws_ami&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;new_image&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  create_before_destroy
&lt;/h3&gt;

&lt;p&gt;By default, when Terraform needs to replace a resource, it destroys the old one first, then creates the new one. This causes downtime.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;lifecycle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;create_before_destroy&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this flag, Terraform creates the new resource first, then destroys the old one. Much better for production.&lt;/p&gt;

&lt;h3&gt;
  
  
  prevent_destroy
&lt;/h3&gt;

&lt;p&gt;Protect critical resources from accidental deletion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;lifecycle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;prevent_destroy&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If anyone runs &lt;code&gt;terraform destroy&lt;/code&gt; targeting this resource, Terraform throws an error instead of deleting it. Essential for databases and storage.&lt;/p&gt;

&lt;h3&gt;
  
  
  ignore_changes
&lt;/h3&gt;

&lt;p&gt;Tell Terraform to ignore changes to specific attributes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;lifecycle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ignore_changes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;instance_type&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful when an external system modifies a resource (like an auto-scaler changing instance counts), and you don't want Terraform to fight it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ Use &lt;code&gt;ignore_changes&lt;/code&gt; carefully. It can hide real configuration problems by instructing Terraform to look away.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  replace_triggered_by
&lt;/h3&gt;

&lt;p&gt;Force a resource to be recreated when something else changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;lifecycle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;replace_triggered_by&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;aws_ami&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;new_image&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the AMI changes, this instance will be rebuilt — even if the instance's own config didn't change.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;What It Does&lt;/th&gt;
&lt;th&gt;Best Used For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;create_before_destroy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;New before old is deleted&lt;/td&gt;
&lt;td&gt;Zero-downtime updates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;prevent_destroy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Blocks accidental deletion&lt;/td&gt;
&lt;td&gt;Databases, critical storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ignore_changes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ignores drift on listed attributes&lt;/td&gt;
&lt;td&gt;Externally managed attributes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;replace_triggered_by&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Forces rebuild on dependency change&lt;/td&gt;
&lt;td&gt;Immutable infra patterns&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  18. Meta-Arguments
&lt;/h2&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%2F2mczjah0geo1xjtt6ogw.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%2F2mczjah0geo1xjtt6ogw.png" alt=" " width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Meta-arguments are special Terraform arguments that control &lt;em&gt;how&lt;/em&gt; Terraform manages a resource — not what the resource itself looks like. They work on any resource type.&lt;/p&gt;

&lt;h3&gt;
  
  
  count — Create Multiple Copies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;count&lt;/span&gt;         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# Creates: web[0], web[1], web[2]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  for_each — Create Named Resources from a Map
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"web"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;frontend&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
    &lt;span class="nx"&gt;backend&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.small"&lt;/span&gt;
    &lt;span class="nx"&gt;worker&lt;/span&gt;   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.medium"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# Creates: web["frontend"], web["backend"], web["worker"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  depends_on — Force Explicit Ordering
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"app"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
  &lt;span class="nx"&gt;depends_on&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;aws_security_group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app_sg&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  lifecycle — Customize Resource Behavior
&lt;/h3&gt;

&lt;p&gt;(Covered in detail in the previous section.)&lt;/p&gt;

&lt;h3&gt;
  
  
  provider — Use a Specific Provider Configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"eu_server"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;provider&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;eu_west&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-eu-123"&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful for multi-region setups where you have multiple provider aliases configured.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Meta-Argument&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;count&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create N copies (index-based)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;for_each&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create named resources from map/set&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;depends_on&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Force dependency order&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lifecycle&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Customize create/update/delete behavior&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;provider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Choose provider alias/configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  19. for_each vs count
&lt;/h2&gt;

&lt;p&gt;Both &lt;code&gt;count&lt;/code&gt; and &lt;code&gt;for_each&lt;/code&gt; create multiple resources, but they behave very differently when you make changes — and the difference matters a lot in production.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem with count
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"servers"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"web"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"api"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"worker"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"servers"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;count&lt;/span&gt;         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;servers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# Creates: servers[0] (web), servers[1] (api), servers[2] (worker)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now imagine you need to remove &lt;code&gt;"api"&lt;/code&gt; from the middle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"web"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"worker"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# removed "api"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Terraform sees that &lt;code&gt;servers[1]&lt;/code&gt; now should be "worker" (which used to be &lt;code&gt;servers[2]&lt;/code&gt;). The result: it &lt;strong&gt;destroys and recreates&lt;/strong&gt; both &lt;code&gt;servers[1]&lt;/code&gt; and &lt;code&gt;servers[2]&lt;/code&gt;. You wanted to delete one server, but you accidentally triggered a replacement of two.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Solution: for_each
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_instance"&lt;/span&gt; &lt;span class="s2"&gt;"servers"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;web&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
    &lt;span class="nx"&gt;api&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.small"&lt;/span&gt;
    &lt;span class="nx"&gt;worker&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.medium"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;instance_type&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
  &lt;span class="nx"&gt;ami&lt;/span&gt;           &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ami-123456"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# Creates: servers["web"], servers["api"], servers["worker"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove &lt;code&gt;api&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;for_each&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;web&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.micro"&lt;/span&gt;
  &lt;span class="nx"&gt;worker&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t2.medium"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Terraform deletes only &lt;code&gt;servers["api"]&lt;/code&gt;. The others are untouched. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;count&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;for_each&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Identifier&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Index (0, 1, 2)&lt;/td&gt;
&lt;td&gt;Key ("web", "api")&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Remove middle item&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Can shift and recreate others&lt;/td&gt;
&lt;td&gt;Only that item deleted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best for&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Identical, interchangeable resources&lt;/td&gt;
&lt;td&gt;Named, distinct resources&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Production use&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Use with caution&lt;/td&gt;
&lt;td&gt;Strongly preferred&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;🔥 &lt;strong&gt;Rule of thumb:&lt;/strong&gt; Default to &lt;code&gt;for_each&lt;/code&gt;. Use &lt;code&gt;count&lt;/code&gt; only for truly identical resources where order doesn't matter.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  20. Version Constraints
&lt;/h2&gt;

&lt;p&gt;Terraform configurations can specify which versions of Terraform itself and its providers are allowed. This is crucial for keeping deployments stable and preventing breaking changes from sneaking in during upgrades.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;terraform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;required_version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;gt;= 1.3.0"&lt;/span&gt;

  &lt;span class="nx"&gt;required_providers&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;aws&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;source&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hashicorp/aws"&lt;/span&gt;
      &lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 5.0"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Constraint Operators Explained
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"= 5.0.0"&lt;/span&gt;    &lt;span class="c1"&gt;# Exactly this version — nothing else&lt;/span&gt;
&lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"!= 5.0.0"&lt;/span&gt;   &lt;span class="c1"&gt;# Anything except this version&lt;/span&gt;
&lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;gt;= 5.0.0"&lt;/span&gt;   &lt;span class="c1"&gt;# This version or newer (⚠️ can reach 6.x — risky!)&lt;/span&gt;
&lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt; 6.0.0"&lt;/span&gt;    &lt;span class="c1"&gt;# Must be below this version&lt;/span&gt;
&lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 5.0"&lt;/span&gt;     &lt;span class="c1"&gt;# &amp;gt;= 5.0.0 and &amp;lt; 6.0.0 (safe minor upgrades)&lt;/span&gt;
&lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 5.2.1"&lt;/span&gt;   &lt;span class="c1"&gt;# &amp;gt;= 5.2.1 and &amp;lt; 5.3.0 (safe patch upgrades only)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;~&amp;gt;&lt;/code&gt; operator (called the &lt;strong&gt;pessimistic constraint operator&lt;/strong&gt;) is the industry standard. It allows safe incremental upgrades while blocking potentially breaking major version changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why This Matters
&lt;/h3&gt;

&lt;p&gt;Without version constraints, a &lt;code&gt;terraform init&lt;/code&gt; today and another six months from now might pull completely different provider versions. Your infrastructure code could start behaving differently without you changing a single line.&lt;/p&gt;

&lt;p&gt;With proper constraints, everyone on the team — and every CI/CD run — uses compatible versions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Best Practice:&lt;/strong&gt; Use &lt;code&gt;~&amp;gt; x.y&lt;/code&gt; for providers (allows patch and minor updates, blocks major). Pin your Terraform version with &lt;code&gt;&amp;gt;= x.y.z, &amp;lt; (next major)&lt;/code&gt; for similar safety.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;You've just covered the full breadth of core Terraform concepts — from how it tracks infrastructure with state, to how it handles dependencies, functions, modules, and deployments.&lt;/p&gt;

&lt;p&gt;Here's a quick summary of the most important ideas to internalize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use implicit dependencies&lt;/strong&gt; whenever possible; reach for &lt;code&gt;depends_on&lt;/code&gt; only when needed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat state as sacred&lt;/strong&gt; — back it up, don't edit it manually without care&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provisioners are a last resort&lt;/strong&gt; — prefer &lt;code&gt;user_data&lt;/code&gt; and proper config management tools&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modules are how you scale&lt;/strong&gt; — small, reusable, single-purpose&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prefer &lt;code&gt;for_each&lt;/code&gt; over &lt;code&gt;count&lt;/code&gt;&lt;/strong&gt; in almost every production situation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutable infrastructure + lifecycle rules&lt;/strong&gt; = stable, reproducible deployments&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version constraints protect you&lt;/strong&gt; from surprise breaking changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Terraform rewards consistent habits. The teams that get the most out of it are the ones that commit to: all changes through code, no manual console edits, modules for reuse, and regular &lt;code&gt;terraform plan&lt;/code&gt; runs to catch drift early.&lt;/p&gt;

&lt;p&gt;Happy building! 🚀&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>devops</category>
      <category>beginners</category>
      <category>aws</category>
    </item>
    <item>
      <title>Protect Your Software Supply Chain with SBOMs – Security and Compliance</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Sat, 04 Oct 2025 12:29:42 +0000</pubDate>
      <link>https://forem.com/abhixsh/protect-your-software-supply-chain-with-sboms-security-and-compliance-225f</link>
      <guid>https://forem.com/abhixsh/protect-your-software-supply-chain-with-sboms-security-and-compliance-225f</guid>
      <description>&lt;p&gt;In today’s software-driven world, applications are no longer built entirely in-house. Instead, they are assembled from hundreds of open-source libraries, third-party dependencies, container images, and vendor components. While this accelerates development, it also creates hidden risks: security vulnerabilities, legal licensing issues, and a lack of visibility into what actually makes up a piece of software.&lt;/p&gt;

&lt;p&gt;This is where a &lt;strong&gt;Software Bill of Materials (SBOM)&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an SBOM?
&lt;/h2&gt;

&lt;p&gt;An &lt;strong&gt;SBOM&lt;/strong&gt; is a &lt;strong&gt;structured inventory or “ingredient list”&lt;/strong&gt; of everything included in a software product.&lt;/p&gt;

&lt;p&gt;It typically contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Component name (log4j-core)&lt;/li&gt;
&lt;li&gt;Version (2.14.1)&lt;/li&gt;
&lt;li&gt;Supplier (e.g., Apache Software Foundation)&lt;/li&gt;
&lt;li&gt;License type (MIT, Apache, GPL, etc.)&lt;/li&gt;
&lt;li&gt;Hash or checksum (for integrity verification)&lt;/li&gt;
&lt;li&gt;Relationships (e.g., Component A depends on Component B)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just like a food label helps consumers understand what they are eating, an SBOM helps organizations, regulators, and customers understand what’s inside their software.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why SBOMs Matter
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a new vulnerability (like Log4Shell in Log4j or critical OpenSSL flaws) is announced, organizations with SBOMs can instantly check whether their systems are affected.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Log4Shell (Log4j)&lt;/strong&gt; = a hidden logging library bug that let hackers run code on servers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenSSL flaws&lt;/strong&gt; = cryptography library bugs that threatened secure communications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Compliance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Many open-source components come with licenses. Some licenses (MIT, Apache) are permissive, while others (GPL, AGPL) impose strict requirements. SBOMs allow legal teams to confirm that distributed software complies with license policies.&lt;/p&gt;

&lt;p&gt;I will explain Licenses in the next section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Regulation &amp;amp; Trust&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Governments and industries are making SBOMs mandatory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;US Executive Order 14028&lt;/strong&gt; → SBOMs required for federal software vendors&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FDA&lt;/strong&gt; → SBOMs required for medical devices&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;EU NIS2 Directive&lt;/strong&gt; → mandates supply chain transparency for critical sectors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most IT companies aim to align with the following standards:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ISO/IEC 27001 &amp;amp; ISO/IEC 27034 (Information Security / Application Security Standards)&lt;/strong&gt;&lt;br&gt;
Scope:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ISO/IEC 27001 → International standard for information security management systems (ISMS).&lt;/li&gt;
&lt;li&gt;ISO/IEC 27034 → Focuses on application security and secure software development practices.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SBOM Relevance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Requires organizations to maintain a comprehensive inventory of software components and assets.&lt;/li&gt;
&lt;li&gt;SBOMs serve as documented evidence for audits, risk assessments, and demonstrating compliance with security controls.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even outside regulation, many enterprises now ask vendors to provide an SBOM before purchasing software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Transparency &amp;amp; Risk Management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SBOMs provide full visibility into dependencies, helping organizations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Respond quickly to security incidents&lt;/li&gt;
&lt;li&gt;Track version history of components&lt;/li&gt;
&lt;li&gt;Understand risks in third-party or outsourced software&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Understanding Open-Source Licenses and SBOMs
&lt;/h2&gt;

&lt;p&gt;When using open-source software, it’s important to know the license that comes with each component. Licenses define how you can use, modify, and distribute the software. They generally fall into three categories: permissive, copyleft (restrictive), and specialized licenses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Permissive Licenses&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Permissive licenses are very flexible. They let you use, modify, and redistribute software with minimal restrictions. You can even include it in proprietary software without having to release your own code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MIT: Very simple; allows use, copy, modify, merge, publish, and distribute; requires attribution.&lt;/li&gt;
&lt;li&gt;Apache 2.0: Allows commercial use; requires notice, provides patent grants, and protects contributors.&lt;/li&gt;
&lt;li&gt;BSD 2-Clause / 3-Clause: Similar to MIT; requires attribution; 3-Clause adds “no endorsement” clause.&lt;/li&gt;
&lt;li&gt;ISC: Very short and permissive, similar to MIT.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use case:&lt;/strong&gt; Perfect for companies that want to include open-source code in their proprietary software without sharing their own source code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Copyleft Licenses (Restrictive)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Copyleft licenses are stricter. If you distribute a modified version of the software, you must release your changes under the same license. This is often called a “viral” license because it applies to your code as well.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GPL (General Public License):&lt;/strong&gt; Strong copyleft; any derivative work must also be GPL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LGPL (Lesser GPL):&lt;/strong&gt; Allows linking to proprietary software; only modifications to the library itself must be open-sourced.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AGPL (Affero GPL):&lt;/strong&gt; Extends GPL; if the software is run over a network (SaaS), the source code must be provided to users.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use case: Good for software that wants improvements to remain open source. Not suitable if you want to keep your code private.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Other Specialized Licenses&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some licenses have specific rules for certain situations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MPL (Mozilla Public License)&lt;/strong&gt; → Only modified files must be open-sourced; the rest of the project can remain proprietary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;EPL (Eclipse Public License)&lt;/strong&gt; → Similar to MPL; modifications to EPL-covered code must be released.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Creative Commons (CC0, CC BY, etc.)&lt;/strong&gt; → Often used for content or data rather than code; some require attribution.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  SBOM Standards
&lt;/h2&gt;

&lt;p&gt;A Software Bill of Materials (SBOM) is only useful if it follows a standard format that tools and organizations can read and process. Two main standards are widely used today:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. CycloneDX&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Origin:&lt;/strong&gt; OWASP project (Open Web Application Security Project).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Focus:&lt;/strong&gt; Security and DevSecOps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; Helps identify vulnerabilities, component versions, and security risks in software.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Format:&lt;/strong&gt; Machine-readable (JSON, XML), so it can be integrated with automated tools like Trivy, Syft, or Dependency-Track.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example Use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatically scan a software build to see if it contains vulnerable libraries.&lt;/li&gt;
&lt;li&gt;Track which components need security patches.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;SPDX (Software Package Data Exchange)&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Origin:&lt;/strong&gt; Linux Foundation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Focus:&lt;/strong&gt; License compliance and legal requirements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; Tracks software licenses, copyright notices, and compliance information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Format:&lt;/strong&gt; Machine-readable (JSON, RDF, tag-value), allowing automated compliance checks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example Use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure no GPL or other restricted-license components are used in a commercial product.&lt;/li&gt;
&lt;li&gt;Generate reports for legal audits or regulatory complianc&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How SBOMs Are Created
&lt;/h2&gt;

&lt;p&gt;SBOMs can be generated automatically using tools:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Syft (Anchore)&lt;/strong&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%2Fuexfdny2rztl3s2uyi4v.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%2Fuexfdny2rztl3s2uyi4v.png" alt=" " width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Syft is an open-source tool from Anchore that generates Software Bill of Materials (SBOMs). An SBOM is a detailed inventory of all software components, libraries, and dependencies inside an application, container image, or filesystem.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Supports multiple SBOM formats:&lt;/li&gt;
&lt;li&gt;CycloneDX JSON&lt;/li&gt;
&lt;li&gt;SPDX JSON&lt;/li&gt;
&lt;li&gt;Table / Text / JSON outputs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Scan a Docker Image&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syft python:3.11
&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%2F3vz8xpjj7g3ay40bcs0j.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%2F3vz8xpjj7g3ay40bcs0j.png" alt=" " width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate SBOM in JSON&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syft python:3.11 -o json &amp;gt; sbom.json
&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%2Fl5ogv83wwphuz06wfeze.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%2Fl5ogv83wwphuz06wfeze.png" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate CycloneDX SBOM&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syft python:3.11 -o cyclonedx-json &amp;gt; sbom-cyclonedx.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Scan a Directory&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syft /path/to/project -o json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Trivy (Aqua Security)&lt;/li&gt;
&lt;/ol&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%2Fjpaqj3rguukmv3pllzgc.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%2Fjpaqj3rguukmv3pllzgc.png" alt=" " width="500" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Trivy (by Aqua Security) is an open-source security and compliance scanner.&lt;/p&gt;

&lt;p&gt;It can scan:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Container images&lt;/li&gt;
&lt;li&gt;File systems / source code&lt;/li&gt;
&lt;li&gt;Git repositories&lt;/li&gt;
&lt;li&gt;Kubernetes clusters&lt;/li&gt;
&lt;li&gt;SBOMs (Software Bill of Materials)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Scan a Docker Image&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;trivy image --format cyclonedx --output sbom.json myapp:latest
&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%2Fw11p2s3j5l5g0vsur2ph.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%2Fw11p2s3j5l5g0vsur2ph.png" alt=" " width="800" height="68"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scan a Directory&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;trivy fs --format cyclonedx --output sbom.json .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Enterprise Tools&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tools like Snyk, Mend, Aqua, or Dependency-Track can automatically:&lt;/li&gt;
&lt;li&gt;Generate SBOMs for multiple projects or containers&lt;/li&gt;
&lt;li&gt;Scan for vulnerabilities&lt;/li&gt;
&lt;li&gt;Track license compliance&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Read an SBOM
&lt;/h2&gt;

&lt;p&gt;An SBOM (Software Bill of Materials) provides detailed information about all the software components in a project. When reading an SBOM, focus on these key elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Components / Packages:&lt;/strong&gt; Lists all the software packages, libraries, and modules used in the project.&lt;/li&gt;
&lt;li&gt;**Version: **Shows the exact version of each component, which is important for tracking vulnerabilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;License:&lt;/strong&gt; Specifies the license type for each component (e.g., MIT, GPL, Apache), helping ensure compliance with organizational or legal requirements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies:&lt;/strong&gt; Indicates which components rely on others, including both direct and transitive dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supplier / Author:&lt;/strong&gt; Names the organization or individual who created or maintains the component.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerabilities (optional):&lt;/strong&gt; Some SBOMs include CVE IDs or risk information for components with known security issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: For small projects, you can read SBOMs manually. For larger projects, use tools like Trivy, Syft, CycloneDX CLI, or Dependency-Track. These tools can visualize dependencies, highlight vulnerabilities, and flag license issues, making SBOMs much easier to interpret.&lt;/p&gt;

&lt;p&gt;We can use the following commands to analyze and visualize SBOM reports:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Trivy:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;trivy sbom sbom.json
&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%2Flasdopbiwziurilpkdzr.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%2Flasdopbiwziurilpkdzr.png" alt=" " width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Grype:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grype sbom:sbom.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What these commands do:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read the SBOM (sbom.json) instead of scanning the image or filesystem again.&lt;/li&gt;
&lt;li&gt;Check all listed components against known vulnerabilities (CVEs).&lt;/li&gt;
&lt;li&gt;Provide a report showing vulnerable packages, severity levels, and available fixes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where SBOMs Are Used
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Security teams&lt;/strong&gt; → Vulnerability detection and monitoring&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legal/compliance teams&lt;/strong&gt; → License validation and audits&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operations teams&lt;/strong&gt;→ Tracking dependencies across environments&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customers and regulators&lt;/strong&gt; → Ensuring transparency before software adoption&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SBOMs can be stored in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Artefact repositories (Nexus, Artifactory, GitHub Packages)&lt;/li&gt;
&lt;li&gt;Container registries (ECR, GCR, ACR — which support SBOM attachments)&lt;/li&gt;
&lt;li&gt;Customer deliverables (JSON/XML files shipped alongside releases)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  SBOM best practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automate generation – use tools, don’t create manually.&lt;/li&gt;
&lt;li&gt;Generate at build time – include all direct and transitive dependencies.&lt;/li&gt;
&lt;li&gt;Store centrally – versioned in artifact or repository.&lt;/li&gt;
&lt;li&gt;Integrate with security tools – scan for vulnerabilities and license issues.&lt;/li&gt;
&lt;li&gt;Choose the right standard – CycloneDX (security) or SPDX (license).&lt;/li&gt;
&lt;li&gt;Update continuously – keep SBOMs current with changes.&lt;/li&gt;
&lt;li&gt;Attach to releases – provide SBOMs with software or containers.&lt;/li&gt;
&lt;li&gt;Use for incident response – quickly identify affected components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>devops</category>
      <category>security</category>
      <category>beginners</category>
    </item>
    <item>
      <title>DNS Basics: How Domain Name System Connects Websites</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Sat, 21 Sep 2024 12:38:49 +0000</pubDate>
      <link>https://forem.com/abhixsh/dns-basics-how-domain-name-system-connects-websites-24jj</link>
      <guid>https://forem.com/abhixsh/dns-basics-how-domain-name-system-connects-websites-24jj</guid>
      <description>&lt;h2&gt;
  
  
  What is DNS?
&lt;/h2&gt;

&lt;p&gt;DNS stands for Domain Name System. It’s like the phonebook of the internet. Instead of remembering long strings of numbers (IP addresses), DNS lets us use easy-to-remember names (like google.com) to visit websites.&lt;/p&gt;

&lt;p&gt;Every device on the internet has an IP address, but DNS allows you to type a simple web address (domain name) and connect to the website without knowing the IP address.&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%2Fxlqzaobhutmuxtnc8m09.jpeg" 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%2Fxlqzaobhutmuxtnc8m09.jpeg" alt="DNS" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How Does DNS Work?
&lt;/h3&gt;

&lt;p&gt;DNS converts (or resolves) a domain name into its IP address so your computer can find and connect to it. Here’s how it works step-by-step:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your browser asks for the IP address of the website you want to visit (like google.com).&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;DNS Resolver&lt;/strong&gt; (usually provided by your internet service) looks for the IP address.&lt;/li&gt;
&lt;li&gt;If it doesn’t have the IP address stored, it contacts a &lt;strong&gt;Root Nameserver&lt;/strong&gt;, which tells the resolver where to find more info.&lt;/li&gt;
&lt;li&gt;The resolver then asks a &lt;strong&gt;TLD Server&lt;/strong&gt; (Top-Level Domain, like .com, .org, etc.) for the right Authoritative Nameserver.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Authoritative Nameserver&lt;/strong&gt; finally gives the correct IP address to the resolver.&lt;/li&gt;
&lt;li&gt;The browser then uses this IP address to connect you to the website.&lt;/li&gt;
&lt;/ol&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%2Ffb2w6unkazqdxdvfm98f.jpeg" 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%2Ffb2w6unkazqdxdvfm98f.jpeg" alt="How DNS work" width="734" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of DNS Records
&lt;/h3&gt;

&lt;p&gt;DNS uses different records to store important information about websites. Here are the most common ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A Record:&lt;/strong&gt; It maps a domain name to an IPv4 address (like 192.168.1.1).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AAAA Record:&lt;/strong&gt; Similar to A Record, but for IPv6 addresses (a newer, longer IP address format).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CNAME Record:&lt;/strong&gt; Points one domain name to another (used when websites have multiple names).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MX Record:&lt;/strong&gt; Directs emails to the correct mail server for a domain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NS Record:&lt;/strong&gt; Lists the nameservers that handle the DNS requests for a domain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SOA Record:&lt;/strong&gt; Contains info about the domain, like when it was last updated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SRV Record:&lt;/strong&gt; Specifies servers for specific services (like email or voice calls).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PTR Record:&lt;/strong&gt; Maps an IP address back to a domain name (reverse lookup).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TXT Record:&lt;/strong&gt; Can store any text, often used for security (like verifying domain ownership).&lt;/li&gt;
&lt;/ul&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%2Fxzjzfd1n1q61xuyepbq7.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%2Fxzjzfd1n1q61xuyepbq7.png" alt="DNS Record Types" width="800" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is DNS Important?
&lt;/h3&gt;

&lt;p&gt;DNS is crucial because it makes the internet easy to use by allowing us to remember names instead of numbers. It also ensures that when you type in a web address, you are sent to the right place. Without DNS, the internet would be much harder to navigate.&lt;/p&gt;

&lt;h3&gt;
  
  
  DNS Challenges
&lt;/h3&gt;

&lt;p&gt;Sometimes, DNS can have problems, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Outages:&lt;/strong&gt; If DNS servers fail, websites can become unreachable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Threats:&lt;/strong&gt; DNS is a target for hackers who may launch attacks like DDoS or cache poisoning, which can take down large portions of the internet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Misconfigurations:&lt;/strong&gt; Small mistakes in DNS setup can lead to websites being down.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Monitoring DNS
&lt;/h3&gt;

&lt;p&gt;To prevent problems, businesses often use DNS monitoring tools to keep track of DNS performance and security. These tools can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check if DNS servers are working well.&lt;/li&gt;
&lt;li&gt;Spot errors or delays in resolving domains.&lt;/li&gt;
&lt;li&gt;Detect security threats like attacks on DNS servers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DNS is the backbone of the internet, allowing us to use simple domain names instead of complex IP addresses. While it’s a powerful system, it can face challenges, so it’s important to monitor and secure DNS to ensure websites and services run smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>networking</category>
      <category>devops</category>
    </item>
    <item>
      <title>Essential Networking Know-How: Insights for DevOps Engineers</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Thu, 09 May 2024 00:21:55 +0000</pubDate>
      <link>https://forem.com/abhixsh/essential-networking-know-how-insights-for-devops-engineers-1ci4</link>
      <guid>https://forem.com/abhixsh/essential-networking-know-how-insights-for-devops-engineers-1ci4</guid>
      <description>&lt;p&gt;Networking is like the wiring that connects all the devices in a house. Just like how electricity flows through wires to power different appliances, data flows through networks to connect computers, smartphones, and other devices. &lt;/p&gt;

&lt;p&gt;For a DevOps engineer, understanding networking is crucial because it's what allows different parts of a system to communicate with each other smoothly. Imagine if the wires in a house were all tangled up or broken - the lights wouldn't turn on, and the appliances wouldn't work. Similarly, if the network isn't set up correctly or has issues, the software and services that DevOps engineers work with might not function properly.&lt;/p&gt;

&lt;p&gt;By knowing about networking, DevOps engineers can ensure that the systems they manage run efficiently and securely. They can set up the right pathways for data to travel, troubleshoot any problems that arise, and keep everything running smoothly, just like an electrician ensures the wiring in a house is in good shape. So, networking is like the backbone of DevOps engineering, making sure everything stays connected and works as it should.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the OSI Model:
&lt;/h2&gt;

&lt;p&gt;Picture your computer as a bustling city, teeming with activity and interconnected pathways. The OSI model serves as our map, dividing this complex system into seven layers, akin to the various strata of a thriving metropolis. Each layer, from the Physical to the Application, plays a distinct role in facilitating the flow of data, much like how different city infrastructures enable daily life.&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%2Fkm09nnjp1lk694ox6oor.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%2Fkm09nnjp1lk694ox6oor.png" alt="Image description" width="800" height="689"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=vv4y_uOneC0&amp;amp;ab_channel=TechTerms" rel="noopener noreferrer"&gt;OSI Model Explained | OSI Animation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TCP/IP Protocol Suite:
&lt;/h2&gt;

&lt;p&gt;Think of TCP/IP as the language spoken by devices on the internet. It's what allows your computer to communicate with servers halfway around the world. Transmission Control Protocol (TCP) ensures that data arrives in the correct order and without errors, while Internet Protocol (IP) is responsible for routing data packets to their destinations. Together, they form the backbone of Internet communication.&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%2F29ez6i6rbnerkpnu3q5i.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%2F29ez6i6rbnerkpnu3q5i.png" alt="Image description" width="714" height="615"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=2QGgEk20RXM&amp;amp;ab_channel=TechTerms" rel="noopener noreferrer"&gt;TCP IP Model Explained | TCP IP Model Animation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Switching and Routing:
&lt;/h2&gt;

&lt;p&gt;Think of switching as having a savvy teacher who effortlessly directs messages to their intended recipients in a crowded classroom. Meanwhile, routing is akin to plotting the optimal path for a letter to reach a friend in another city, with routers acting as the gatekeepers guiding data through networks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/results?search_query=Switching+and+Routing" rel="noopener noreferrer"&gt;- Switching Techniques in Computer Networks&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  IP Link, IP Addressing, and Subnetting:
&lt;/h2&gt;

&lt;p&gt;Every device on a network, be it your trusty smartphone or reliable computer, is assigned a unique identifier – the IP address. It's akin to having a personal phone number in the digital realm. Utilizing commands like &lt;code&gt;ip link&lt;/code&gt; and &lt;code&gt;ip addr add&lt;/code&gt;, you can explore your device's connection and even add additional IP addresses as needed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=OqsXzkXfwRw&amp;amp;ab_channel=TechTerms" rel="noopener noreferrer"&gt;IP addressing and Subnetting&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Gateway and Default Gateway:
&lt;/h2&gt;

&lt;p&gt;Just as you rely on GPS navigation to reach unfamiliar destinations, your computer relies on gateways to access external networks. Commands like &lt;code&gt;route&lt;/code&gt; and &lt;code&gt;ip route add&lt;/code&gt; help configure routing tables, while &lt;code&gt;ping&lt;/code&gt; tests connectivity, ensuring smooth communication with other networks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=pCcJFdYNamc&amp;amp;ab_channel=PowerCertAnimatedVideos" rel="noopener noreferrer"&gt;- Default Gateway Explained&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  DNS Server:
&lt;/h2&gt;

&lt;p&gt;Ever wondered how your computer effortlessly translates web addresses like "google.com" into numerical IP addresses? Enter DNS servers, the unsung heroes of internet navigation. Commands like &lt;code&gt;nslookup&lt;/code&gt; and &lt;code&gt;dig&lt;/code&gt; offer glimpses into the inner workings of this crucial translation process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=mpQZVYPuDGU&amp;amp;ab_channel=PowerCertAnimatedVideos" rel="noopener noreferrer"&gt;How a DNS Server (Domain Name System) works.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Network Security:
&lt;/h2&gt;

&lt;p&gt;Much like locking your doors to thwart intruders, network security safeguards data from unauthorized access. Firewalls, VPNs, and encryption protocols serve as digital guardians, ensuring the integrity and confidentiality of your online interactions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=zd0U1zNBYNk&amp;amp;ab_channel=NesoAcademy" rel="noopener noreferrer"&gt;Network Security Model&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Load Balancing:
&lt;/h2&gt;

&lt;p&gt;Imagine a bustling restaurant efficiently serving scores of hungry patrons. Load balancing distributes network traffic across multiple servers, ensuring smooth and reliable access to websites and applications, even during peak usage periods.&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%2F1yuisljhlbdn58gc71ux.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%2F1yuisljhlbdn58gc71ux.png" alt="Image description" width="800" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=sCR3SAVdyCc&amp;amp;ab_channel=IBMTechnology" rel="noopener noreferrer"&gt;What is a Load Balancer?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Network Monitoring and Troubleshooting:
&lt;/h2&gt;

&lt;p&gt;Just as a skilled mechanic diagnoses and repairs car troubles, network engineers employ tools and techniques to monitor and troubleshoot network issues. From identifying bottlenecks to swiftly resolving connectivity hiccups, their expertise ensures seamless digital experiences for users.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=SK8D1bdJh7s&amp;amp;ab_channel=ITkFunde" rel="noopener noreferrer"&gt;How to troubleshoot network issues&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, there you have it, aspiring tech wizards! Armed with newfound knowledge and handy commands, you're well-equipped to navigate the intricate web of computer networking. Whether you're exploring the depths of the OSI model or delving into the nuances of DNS translation, each concept brings you one step closer to mastering the art of networking. So go ahead, dive in, and unravel the mysteries of networking – the digital realm awaits your exploration!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Useful Things!&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=rurs7cdT5cc&amp;amp;ab_channel=NesoAcademy" rel="noopener noreferrer"&gt;Basic Networking Commands Video&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://d2cpnw0u24fjm4.cloudfront.net/wp-content/uploads/Network-CLI-Commands.pdf" rel="noopener noreferrer"&gt;Network CLI Commands pdf&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=IPvYjXCsTg8&amp;amp;t=45s&amp;amp;ab_channel=KunalKushwaha" rel="noopener noreferrer"&gt;Computer Networking Full Course&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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%2Fytitz2wt4jsufejox9yx.gif" 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%2Fytitz2wt4jsufejox9yx.gif" alt="Image description" width="498" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>networking</category>
      <category>beginners</category>
      <category>devops</category>
      <category>linux</category>
    </item>
    <item>
      <title>Unlocking Linux: A Beginner's Guide to Essential Commands and Functions</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Wed, 08 May 2024 09:12:13 +0000</pubDate>
      <link>https://forem.com/abhixsh/unlocking-linux-a-beginners-guide-to-essential-commands-and-functions-1moe</link>
      <guid>https://forem.com/abhixsh/unlocking-linux-a-beginners-guide-to-essential-commands-and-functions-1moe</guid>
      <description>&lt;p&gt;Linux is like the engine that powers a lot of the internet. It's everywhere, from websites to smartphones to supercomputers. As a DevOps engineer, you work with software and systems to make sure everything runs smoothly. Linux is crucial for this because it's stable, secure, and flexible. It's also free, which is great for businesses. Learning Linux helps you understand how to manage servers, automate tasks, and deploy applications. So, if you want to be a DevOps engineer, learning Linux is like learning the language of the internet!&lt;/p&gt;

&lt;p&gt;Linux, the operating system powering much of today's digital world, might seem like a complex maze to navigate, but fear not! In this beginner-friendly guide, we'll embark on a journey through the world of Linux, starting from its basic concepts to essential commands and functionalities. By the end of this article, you'll have a solid understanding of Linux, empowering you to navigate its ecosystem with confidence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Linux Shell Types
&lt;/h3&gt;

&lt;p&gt;Think of the Linux shell as your gateway to interacting with the operating system. There are different types of shells, each with its unique features. Let's explore a few:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Bourne Shell (sh shell)&lt;/strong&gt;: This is one of the oldest and simplest shells. It's efficient for running scripts and executing commands.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=I4EWvMFj37g&amp;amp;ab_channel=Fireship" rel="noopener noreferrer"&gt;Bash in 100 Seconds&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;C Shell (csh or tcsh)&lt;/strong&gt;: Known for its C-like syntax, this shell offers powerful scripting capabilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Z Shell (zsh)&lt;/strong&gt;: Zsh is highly customizable and comes with advanced features like improved tab completion and spelling correction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bourne Again Shell (bash)&lt;/strong&gt;: Perhaps the most widely used shell, bash combines the features of the older shells with additional enhancements, making it user-friendly and versatile.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Basic Linux Commands
&lt;/h3&gt;

&lt;p&gt;Now, let's dive into some basic Linux commands that you'll use frequently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Echo&lt;/strong&gt;: Used to print messages to the terminal. For example, &lt;code&gt;echo "Hello, Linux!"&lt;/code&gt; will display "Hello, Linux!" on the screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ls&lt;/strong&gt;: Short for "list," this command displays the contents of a directory. For instance, &lt;code&gt;ls /home&lt;/code&gt; will show the files and folders in the "/home" directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;cd&lt;/strong&gt;: Stands for "change directory," allowing you to navigate between directories. Example: &lt;code&gt;cd /var/www&lt;/code&gt; moves you to the "/var/www" directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;pwd&lt;/strong&gt;: Displays the present working directory. Typing &lt;code&gt;pwd&lt;/code&gt; will show you the directory you're currently in.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;mkdir&lt;/strong&gt;: Short for "make directory," used to create new directories. For example, &lt;code&gt;mkdir documents&lt;/code&gt; creates a new directory named "documents."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://iitd-plos.github.io/col100/references/Linuxppt.pdf" rel="noopener noreferrer"&gt;Basic Linux Commands&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Command Files
&lt;/h3&gt;

&lt;p&gt;Understanding how to manipulate files is fundamental in Linux. Here are some essential commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;touch&lt;/strong&gt;: Creates an empty file. For instance, &lt;code&gt;touch myfile.txt&lt;/code&gt; creates a file named "myfile.txt."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;cat&lt;/strong&gt;: Concatenates and displays the content of files. Typing &lt;code&gt;cat myfile.txt&lt;/code&gt; will show the contents of "myfile.txt" on the screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;cp&lt;/strong&gt;: Copies files or directories. Example: &lt;code&gt;cp file1.txt /backup&lt;/code&gt; copies "file1.txt" to the "/backup" directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;mv&lt;/strong&gt;: Moves files or directories. For instance, &lt;code&gt;mv file1.txt /new_location&lt;/code&gt; moves "file1.txt" to "/new_location."&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Introduction to VI Editor
&lt;/h3&gt;

&lt;p&gt;VI is a powerful text editor commonly used in Linux. It has two modes: command mode and insert mode. Here are some basic commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;i&lt;/strong&gt;: Switches to insert mode, allowing you to insert text.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;x or dd&lt;/strong&gt;: Deletes characters (x) or entire lines (dd).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;yy or p&lt;/strong&gt;: Copies (yy) and pastes (p) text.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ctrl + u /d&lt;/strong&gt;: Scrolls up/down.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:w&lt;/strong&gt;: Saves changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:q&lt;/strong&gt;: Quits VI.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:wq&lt;/strong&gt;: Saves changes and quits.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=-_DvfdgR-LA&amp;amp;ab_channel=LabIT" rel="noopener noreferrer"&gt;Basics of VI editor in under 8 minutes&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Managing User Accounts
&lt;/h3&gt;

&lt;p&gt;Linux allows you to manage user accounts efficiently. Here are some commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;whoami&lt;/strong&gt;: Displays the current username.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;id&lt;/strong&gt;: Shows information about the current user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;su&lt;/strong&gt;: Switches user. For example, &lt;code&gt;su username&lt;/code&gt; switches to the user "username."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ls /root&lt;/strong&gt;: Lists the contents of the root directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;sudo ls /root&lt;/strong&gt;: Lists the root directory with superuser privileges.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Downloading Files
&lt;/h3&gt;

&lt;p&gt;Downloading files is a common task in Linux. Here are two methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;curl&lt;/strong&gt;: Downloads files from a URL. Example: &lt;code&gt;curl http://example.com/file.txt -o file.txt&lt;/code&gt; downloads "file.txt" from "&lt;a href="http://example.com" rel="noopener noreferrer"&gt;http://example.com&lt;/a&gt;" and saves it locally.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;wget&lt;/strong&gt;: Similar to curl, wget also downloads files from URLs. Example: &lt;code&gt;wget http://example.com/file.txt&lt;/code&gt; downloads "file.txt" from "&lt;a href="http://example.com" rel="noopener noreferrer"&gt;http://example.com&lt;/a&gt;."&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Package Managers
&lt;/h3&gt;

&lt;p&gt;Package managers simplify the installation and management of software packages. Let's explore two popular package managers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/watch?v=9zXBco0Zs3c&amp;amp;t=71s&amp;amp;ab_channel=45Drives" rel="noopener noreferrer"&gt;RPM (Red Hat Package Manager)&lt;/a&gt;&lt;/strong&gt;: Used primarily in Red Hat-based distributions like CentOS. Commands include &lt;code&gt;rpm -i&lt;/code&gt; for installation, &lt;code&gt;rpm -e&lt;/code&gt; for removal, and &lt;code&gt;rpm -q&lt;/code&gt; for querying package information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/watch?v=i0G0cuYv7eo&amp;amp;t=64s&amp;amp;ab_channel=RedHat" rel="noopener noreferrer"&gt;Yum&lt;/a&gt;&lt;/strong&gt;: A high-level package management tool built on top of RPM. Common commands include &lt;code&gt;yum install&lt;/code&gt; for installation, &lt;code&gt;yum remove&lt;/code&gt; for removal, and &lt;code&gt;yum repolist&lt;/code&gt; for listing repositories.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Managing Services in Linux
&lt;/h3&gt;

&lt;p&gt;Linux services are background processes that run continuously. Here's how to manage them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Service&lt;/strong&gt;: Command-line tool for managing system services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Systemctl&lt;/strong&gt;: Controls the systemd system and service manager. Commands include &lt;code&gt;start&lt;/code&gt;, &lt;code&gt;stop&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt;, &lt;code&gt;enable&lt;/code&gt;, and &lt;code&gt;disable&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=3kl62YSU9XA&amp;amp;ab_channel=AkamaiDeveloper" rel="noopener noreferrer"&gt;How To Manage Linux Services with systemctl and journalctl | Sysadmin Basics&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Congratulations! You've taken your first steps into the fascinating world of Linux. Armed with this knowledge, you're ready to explore further and unlock the endless possibilities that Linux offers. Keep practicing, experimenting, and embracing the open-source spirit. Happy learning!&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%2Fytitz2wt4jsufejox9yx.gif" 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%2Fytitz2wt4jsufejox9yx.gif" alt="Image description" width="498" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>devops</category>
      <category>bash</category>
      <category>linux</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Docker for the Absolute Beginner</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Wed, 27 Dec 2023 07:39:48 +0000</pubDate>
      <link>https://forem.com/abhixsh/docker-for-the-absolute-beginner-3h1p</link>
      <guid>https://forem.com/abhixsh/docker-for-the-absolute-beginner-3h1p</guid>
      <description>&lt;p&gt;Docker is a tool that allows developers to package their applications and all their dependencies into a single container. This container can then be easily transported and run on any machine that has Docker installed, without worrying about differences in the environment. It's like a standardized way of packaging and running software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the container?&lt;/strong&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%2Fimsgbstga86vnxjwgebr.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%2Fimsgbstga86vnxjwgebr.png" alt="Docker container" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;container is like a little package that has everything a program needs to run, making it easy to move around and run on different computers without causing any trouble. &lt;/p&gt;

&lt;p&gt;The cool part is that this mini-computer (container) is like a superhero with a cape. It can run on any computer, no matter how different they are, because it brings its own special environment with it. It's a neat and tidy way to keep software organized and make sure it works the same way no matter where it goes.&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%2F1z5zcued8ya2onerpzwt.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%2F1z5zcued8ya2onerpzwt.png" alt="container" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why do we need Docker?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; Docker makes sure that the software works the same way on your computer, your friend's computer, or any computer. It keeps things consistent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portability:&lt;/strong&gt; You can package up your software and its friends into a Docker container, and it can travel anywhere. It's like putting your game and all its rules in a suitcase and playing it at a friend's house.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolation:&lt;/strong&gt; Docker containers are like little bubbles. What happens inside the bubble stays inside the bubble. This means one program in a container won't mess with another program outside its container.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency:&lt;/strong&gt; Docker helps save computer resources. Instead of having a whole computer just for one program, you can have many containers running on the same computer without them getting in each other's way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speed:&lt;/strong&gt; Docker makes it quick and easy to start, stop, and share software. It's like turning on and off a game console – fast and simple.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;what is Docker Image?&lt;/strong&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%2F817t1rsad728snnighkj.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%2F817t1rsad728snnighkj.png" alt="Docker Image " width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Docker image is a snapshot of a program and all the things it needs to run. It's a packed-up version that includes the code, tools, and settings, just like a snapshot of your cookie recipe with all the ingredients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The image is the recipe, and the container is what you get when you follow that recipe to actually make and run the program.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some Basic Docker Commands.&lt;/strong&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%2Fxq1pwt8896lvster3ppl.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%2Fxq1pwt8896lvster3ppl.png" alt="Basic Docker Commands" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker run nginx&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This command tells Docker to run a container using the "nginx" image. It's like telling Docker to start a new instance of a pre-made program (nginx, which is a web server).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker ps&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shows you a list of running containers. It's like checking to see which programs are currently running.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker ps -a&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shows you a list of all containers, including the ones that have stopped. It's like checking a history of all the programs you've run.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker stop silly_sammet&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stops a running container named "silly_sammet." It's like turning off a program that's currently running.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker rm silly_sammet&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Removes a stopped container named "silly_sammet." It's like throwing away the instructions for a program you don't need anymore.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker images&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lists all the Docker images you have. It's like looking at a menu of all the different programs you can run.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker rmi nginx&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Removes the "nginx" image. It's like erasing the recipe for a program you don't want to use anymore.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker pull nginx&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Downloads the "nginx" image from the internet. It's like getting a new recipe from a cookbook.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker run ubuntu sleep 5&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Runs a container using the "ubuntu" image and makes it sleep for 5 seconds. It's like starting a program that just waits for a little bit and then stops.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker exec distracted_mcclintock cat /etc/hosts&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Executes a command inside a running container named "distracted_mcclintock." It's like peeking inside the recipe book to see a specific page.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker run -d kodekloud/simple-webapp&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Runs a container in detached mode from the "kodekloud/simple-webapp" image. It's like starting a program and letting it run in the background.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker attach a043d&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Attaches your terminal to a running container with the ID "a043d." It's like jumping into a running program to see what's happening.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Some Docker concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Run with a Tag:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tags are like versions of a program. It's specifying which version you want to run.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker run nginx:latest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This runs the latest version of the Nginx program.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Run with STDIN:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;STDIN is like typing on your keyboard. Some programs want input from you.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker run -i -t ubuntu&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This runs an interactive terminal inside a Ubuntu container, allowing you to type commands.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Run with Port Mapping:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ports are like doors. Programs use them to communicate with the outside world.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker run -p 8080:80 nginx&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This runs Nginx, and it opens the door on your computer's port 8080, connecting it to the container's port 80.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Run with Volume Mapping:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Volumes are like shared folders. They let you store things outside the container.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker run -v /your/local/folder:/container/folder nginx&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This runs Nginx and connects a folder on your computer to a folder inside the container.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Inspect Container:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inspecting is like taking a closer look at a running program.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker inspect container_name&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This gives you detailed information about a running or stopped container.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Container Logs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logs are like a diary. They record what a program has been doing.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker logs container_name&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This shows you the logs or activities of a specific container.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Environment variables
&lt;/h2&gt;

&lt;p&gt;environment variables are like handy notes that programs use to find important information, kind of like secret messages for the program to understand and work better!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Environment Variables in a Python Script (app.py):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Imagine you have a program (app.py) written in Python. You might want to customize it without changing the code. You can use environment variables.&lt;/li&gt;
&lt;li&gt;Example Code (app.py):
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

 &lt;span class="n"&gt;app_color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;APP_COLOR&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;default_color&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The app color is &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;app_color&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Running the script normally: &lt;code&gt;python app.py&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Running with a specific color: &lt;code&gt;export APP_COLOR=blue; python app.py&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Using ENV Variables in Docker:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker containers can also use environment variables. It's like giving instructions to the program inside the container.&lt;/li&gt;
&lt;li&gt;Example Code:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;docker run -e APP_COLOR=green simple-webapp-color&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;This runs a Docker container (&lt;code&gt;simple-webapp-color&lt;/code&gt;) and sets the environment variable &lt;code&gt;APP_COLOR&lt;/code&gt; to "green".&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Inspecting Environment Variables:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sometimes, you want to check what environment variables a running container is using.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker inspect blissful_hopper&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This command provides detailed information about the container named "blissful_hopper," including its environment variables.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In simple terms, environment variables are like little notes that a program (or a Docker container) can read to know how to behave. You can set these notes before running the program, and the program will use them to customize itself. The &lt;code&gt;export&lt;/code&gt; command in the second example is like writing a note before running a program, telling it how to behave. The &lt;code&gt;docker inspect&lt;/code&gt; command is like peeking inside a container to see what notes it has.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Images
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Dockerfile:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Dockerfile is like a set of instructions for Docker to create an image. It's like a recipe for baking a cake.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use the Ubuntu base image&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; Ubuntu&lt;/span&gt;

&lt;span class="c"&gt;# Update apt repository&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get update

&lt;span class="c"&gt;# Install dependencies using apt&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; python

&lt;span class="c"&gt;# Install Python dependencies using pip&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;flask
&lt;span class="k"&gt;RUN &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;flask-mysql

&lt;span class="c"&gt;# Copy source code to /opt folder&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . /opt/source-code&lt;/span&gt;

&lt;span class="c"&gt;# Set the working directory&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /opt/source-code&lt;/span&gt;

&lt;span class="c"&gt;# Specify entry point to run the web server&lt;/span&gt;
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["flask", "run"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Steps to Create Your Own Image:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a file named &lt;code&gt;Dockerfile&lt;/code&gt; with the above content.&lt;/li&gt;
&lt;li&gt;Save it in the same directory as your source code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Building the Docker Image:&lt;/strong&gt;&lt;br&gt;
Run the following command in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; your-image-name &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command tells Docker to build an image using the Dockerfile in the current directory (&lt;code&gt;.&lt;/code&gt;), and tag it with a name of your choice (&lt;code&gt;-t your-image-name&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layered Architecture:&lt;/strong&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%2F9i91e79dg61wnbbfp62m.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%2F9i91e79dg61wnbbfp62m.png" alt="Layered Architecture" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Think of the Docker image as a layered cake. Each instruction in the Dockerfile adds a layer to the image.&lt;/li&gt;
&lt;li&gt;Layers are reusable. If you change something in your code, Docker only rebuilds the layer affected, making it efficient.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Docker Build Output:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you build an image, Docker shows each step in the process. If there's a failure, it'll give you an error message.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What Can You Containerize?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Almost anything! Applications, services, databases, websites, basically any software can be containerized.&lt;/li&gt;
&lt;li&gt;It's like putting your software in a box so it can run anywhere without causing trouble.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Docker CMD vs ENTRYPOINT
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;CMD&lt;/code&gt; in Docker:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Think of CMD as the default thing your program does when you start the container.&lt;/li&gt;
&lt;li&gt;It's like saying, "Hey, when you run this container, do this by default."&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;CMD ["flask", "run"]&lt;/code&gt; means when the container starts, it automatically runs the Flask web server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CMD Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; alpine&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["sleep", "5"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, when you run a container using this image, it automatically sleeps for 5 seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;ENTRYPOINT&lt;/code&gt; in Docker:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Think of ENTRYPOINT as the main thing your container does. It's like the boss command.&lt;/li&gt;
&lt;li&gt;It sets a default application to run when the container starts, but you can still override it if you want.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;ENTRYPOINT ["flask", "run"]&lt;/code&gt; means the container is primarily meant to run the Flask web server, but you can still add more commands if needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;ENTRYPOINT Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; alpine&lt;/span&gt;
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["sleep"]&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["5"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the primary purpose is to sleep, and you can still override the sleep duration if you want.&lt;/p&gt;

&lt;p&gt;In both cases, the container will just sleep for a few seconds when started. The key difference is in how you provide parameters and whether or not they can be easily overridden.&lt;/p&gt;

&lt;p&gt;CMD is like saying, "Here's a default thing to do," and ENTRYPOINT is like saying, "This is the main thing to do, but you can tweak it a bit if you want." They both help define what your container does when it starts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Networking in Docker:
&lt;/h2&gt;

&lt;p&gt;Docker networking helps containers (programs) talk to each other, making sure they can work together smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default Networks:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker creates default networks for containers to communicate.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker run ubuntu --network=host&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;This runs a Ubuntu container using the host network, meaning it shares the network namespace with the host.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;User-Defined Networks:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can create your own networks for better organization and control.&lt;/li&gt;
&lt;li&gt;Example Code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  docker network create &lt;span class="nt"&gt;--driver&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;bridge &lt;span class="nt"&gt;--subnet&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;182.18.0.0/16 custom-isolated-network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This creates a user-defined bridge network named &lt;code&gt;custom-isolated-network&lt;/code&gt; with a specific subnet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Listing Networks:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can see all the networks you have.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker network ls&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Inspecting a Network:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can inspect the details of a specific network.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;docker network inspect blissful_hopper&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;This shows detailed information about the network named "blissful_hopper."&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Embedded DNS:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker has a built-in DNS system for containers to find each other by name.&lt;/li&gt;
&lt;li&gt;Example Code: &lt;code&gt;mysql.connect(mysql)&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;This could be a line in your code where a service named "mysql" connects to another service named "mysql" using Docker's DNS.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Docker Storage:
&lt;/h2&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%2F7i54a6m0o1tb0812xbjk.jpg" 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%2F7i54a6m0o1tb0812xbjk.jpg" alt="Docker Storage" width="671" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Docker storage is like deciding where to keep your data when using containers. You can keep them inside the container, share them between containers using volumes, or store them outside the container for safekeeping.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File System in Docker:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker uses a layered architecture to build images. Each instruction in the Dockerfile adds a new layer to the filesystem.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Dockerfile&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; Ubuntu&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; python
&lt;span class="k"&gt;RUN &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;flask flask-mysql
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . /opt/source-code&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /opt/source-code&lt;/span&gt;
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["flask", "run"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The layers in the Dockerfile:

&lt;ul&gt;
&lt;li&gt;Layer 1: Base Ubuntu layer&lt;/li&gt;
&lt;li&gt;Layer 2: Changes in apt packages&lt;/li&gt;
&lt;li&gt;Layer 3: Changes in pip packages&lt;/li&gt;
&lt;li&gt;Layer 4: Source code&lt;/li&gt;
&lt;li&gt;Layer 5: Update Entrypoint with "flask" command&lt;/li&gt;
&lt;li&gt;Layer 6: Container Layer&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Image Layers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you build a Docker image, it consists of read-only layers. Each layer represents a change or addition to the image.

&lt;ul&gt;
&lt;li&gt;Layer 1: Base Ubuntu layer&lt;/li&gt;
&lt;li&gt;Layer 2: Changes in apt packages&lt;/li&gt;
&lt;li&gt;Layer 3: Changes in pip packages&lt;/li&gt;
&lt;li&gt;Layer 4: Source code&lt;/li&gt;
&lt;li&gt;Layer 5: Update Entrypoint with "flask" command
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Build the Docker image&lt;/span&gt;
docker build &lt;span class="nt"&gt;-t&lt;/span&gt; mmumshad/my-custom-app &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Container Layer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you run a Docker container, a read-write layer is added on top of the read-only image layers. This layer is specific to the running container.

&lt;ul&gt;
&lt;li&gt;Layer 6. Container Layer
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Run the Docker container&lt;/span&gt;
docker run mmumshad/my-custom-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Volumes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Volumes are a way to persist data outside the container. They are like external storage.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a Docker volume&lt;/span&gt;
docker volume create data_volume

&lt;span class="c"&gt;# Use the volume in a container&lt;/span&gt;
docker run &lt;span class="nt"&gt;-v&lt;/span&gt; data_volume:/var/mysql mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can also mount specific directories from the host to the container using &lt;code&gt;-v&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Mount a host directory to a container directory&lt;/span&gt;
docker run &lt;span class="nt"&gt;-v&lt;/span&gt; /path/on/host:/var/mysql/mysql &lt;span class="nt"&gt;-d&lt;/span&gt; mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The docker run --mount command is used to mount a specific directory or file from the host machine into a running Docker container.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --mount type=bind,source=/mysql,target=/var/mysql mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Storage Drivers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker uses storage drivers to manage how data is stored and accessed. Some common storage drivers include AUFS, ZFS, BTRFS, Device Mapper, Overlay, and Overlay2.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://docs.docker.com/storage/" rel="noopener noreferrer"&gt;Manage data in Docker&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/storage/storagedriver/" rel="noopener noreferrer"&gt;About storage drivers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/storage/volumes/" rel="noopener noreferrer"&gt;Volumes&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Docker Compose
&lt;/h2&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%2Fyjyro6o2844s2or1b83c.jpeg" 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%2Fyjyro6o2844s2or1b83c.jpeg" alt="Docker Compose" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Docker Compose is a handy tool that helps you easily run and connect different software services as if they were all part of the same event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Compose Basics:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Running Individual Containers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Normally, you might run separate Docker containers like this:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker run mmumshad/simple-webapp
 docker run mongodb
 docker run redis:alpine
 docker run ansible
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Docker Compose File (&lt;code&gt;docker-compose.yml&lt;/code&gt;):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker Compose allows you to define all these services in a simple file:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt; &lt;span class="c1"&gt;# docker-compose.yml&lt;/span&gt;
 &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3'&lt;/span&gt;

 &lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;mmumshad/simple-webapp'&lt;/span&gt;
   &lt;span class="na"&gt;database&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;mongodb'&lt;/span&gt;
   &lt;span class="na"&gt;messaging&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;redis:alpine'&lt;/span&gt;
   &lt;span class="na"&gt;orchestration&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ansible'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;This file describes the services you want to run (&lt;code&gt;web&lt;/code&gt;, &lt;code&gt;database&lt;/code&gt;, &lt;code&gt;messaging&lt;/code&gt;, &lt;code&gt;orchestration&lt;/code&gt;), their respective images, and any additional configurations.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Running with Docker Compose:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To start all these services together:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker-compose up
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Docker Compose takes care of starting all the containers defined in your &lt;code&gt;docker-compose.yml&lt;/code&gt; file.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Building with Docker Compose:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can also build images using Docker Compose:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker-compose build
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;This command builds the images specified in the &lt;code&gt;docker-compose.yml&lt;/code&gt; file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Running Linked Containers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If you were to run individual containers with linking:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt; docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; redis redis
 docker run &lt;span class="nt"&gt;--name&lt;/span&gt; voting-app &lt;span class="nt"&gt;-p&lt;/span&gt; 5000:80 &lt;span class="nt"&gt;--link&lt;/span&gt; redis:redis voting-app
 docker run &lt;span class="nt"&gt;--name&lt;/span&gt; result-app &lt;span class="nt"&gt;-p&lt;/span&gt; 5001:80 &lt;span class="nt"&gt;--link&lt;/span&gt; db:db result-app
 docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; worker &lt;span class="nt"&gt;--link&lt;/span&gt; db:db &lt;span class="nt"&gt;--link&lt;/span&gt; redis:redis worker
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;In Docker Compose:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight yaml"&gt;&lt;code&gt; &lt;span class="c1"&gt;# docker-compose.yml&lt;/span&gt;
 &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3'&lt;/span&gt;

 &lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="na"&gt;vote&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;voting-app'&lt;/span&gt;
     &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
       &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;5000:80'&lt;/span&gt;
     &lt;span class="na"&gt;links&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
       &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;redis:redis'&lt;/span&gt;
   &lt;span class="na"&gt;result&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;result-app'&lt;/span&gt;
     &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
       &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;5001:80'&lt;/span&gt;
     &lt;span class="na"&gt;links&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
       &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;db:db'&lt;/span&gt;
   &lt;span class="na"&gt;worker&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;worker'&lt;/span&gt;
     &lt;span class="na"&gt;links&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
       &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;db:db'&lt;/span&gt;
       &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;redis:redis'&lt;/span&gt;
   &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;db'&lt;/span&gt;
   &lt;span class="na"&gt;redis&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;redis'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Docker Compose lets you describe your entire application stack in a single file, making it easy to manage, run, and connect different services. It's like writing down all the tasks for your event in one plan, and then Docker Compose handles the setup for you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.docker.com/compose/" rel="noopener noreferrer"&gt;Docker Compose overview&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/engine/reference/commandline/compose/" rel="noopener noreferrer"&gt;Docker compose Doc&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Docker Registry
&lt;/h2&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%2Fbzflp82qyg36y8fcf8k8.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%2Fbzflp82qyg36y8fcf8k8.png" alt="Docker Registry" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;a Docker Registry is a place where people store and share their Docker images, making it easy for others to use and run their software. It's like a big online library for programs that can be easily downloaded and used on different computers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Registry Basics:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Public Registry:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker images can be stored and shared on public registries like Docker Hub.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker pull nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Private Registry:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sometimes, you might want to keep your images in your own private registry.&lt;/li&gt;
&lt;li&gt;Example:

&lt;ul&gt;
&lt;li&gt;Log in to a private registry:
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bash
       docker login private-registry.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - Run a container from an image in the private registry:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ```bash
   docker run private-registry.io/apps/internal-app
   ```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Deploying Your Own Private Registry:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;You can deploy your own private registry for your team or company.&lt;/li&gt;
&lt;li&gt;Example:

&lt;ul&gt;
&lt;li&gt;Run a private registry on your machine:
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;       docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 5000:5000 &lt;span class="nt"&gt;--name&lt;/span&gt; registry registry:2
       &lt;span class="sb"&gt;```&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;% endraw %&lt;span class="o"&gt;}&lt;/span&gt;

     - Tag your image &lt;span class="k"&gt;for &lt;/span&gt;the private registry:
&lt;span class="o"&gt;{&lt;/span&gt;% raw %&lt;span class="o"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;bash&lt;br&gt;
       docker image tag my-image localhost:5000/my-image&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


     - Push the image to your private registry:



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

&lt;/div&gt;
&lt;p&gt;bash&lt;br&gt;
       docker push localhost:5000/my-image&lt;br&gt;
       ```&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - Pull the image from your private registry:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  bash
       docker pull localhost:5000/my-image 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Pulling from a Remote Private Registry:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can also pull images from a remote private registry using its IP address or domain.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker pull 192.168.56.100:5000/my-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;a Docker Registry is like a storage space where people keep and share their Docker images. You can use public registries for widely-used images or set up your own private registry for your specific needs. It's like a special library for sharing and storing software blueprints (images).&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Engine
&lt;/h2&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%2Fhc6r4dvo9kg9xqgwsrbb.jpg" 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%2Fhc6r4dvo9kg9xqgwsrbb.jpg" alt="Docker Engine" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine you have a magic box (Docker Engine) that can run and manage all kinds of programs (containers) for you. Docker Engine is like the brain of this magic box.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Docker Daemon:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Daemon is like the caretaker of the magic box. It's always there, ready to take instructions and make sure everything runs smoothly.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;REST API:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Think of REST API as a set of rules that allow you to talk to the magic box. It's like a language that you and the Daemon use to communicate. You tell the Daemon what to do, and it understands because you're speaking the same language.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Docker CLI (Command Line Interface):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Docker CLI is like a magical wand you use to command the Daemon. You type in commands, and the Daemon follows your instructions. It's like saying "Abracadabra" to make things happen.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Connecting to a Remote Docker Engine:&lt;/strong&gt;&lt;br&gt;
connecting to a remote Docker engine allows you to control containers on another machine, and setting constraints ensures that containers use only specified resources. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Docker Host IP:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can connect to a Docker engine on a different machine using its IP address and port.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker &lt;span class="nt"&gt;-H&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;remote-docker-engine:2375 run nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;This tells your local Docker CLI to communicate with a remote Docker engine.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Running Container with Constraints:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker allows you to set resource constraints for containers, like CPU and memory limits.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker run &lt;span class="nt"&gt;--cpus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.5 ubuntu
 docker run &lt;span class="nt"&gt;--memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;100m ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;These commands limit the container to use only half a CPU core and 100 megabytes of memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sure, let's simplify the concept of PID namespace:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Namespace PID:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PID namespace allows you to create a separate area for processes (like programs or tasks) in a container, so they have their own set of "ticket numbers" (Process IDs) that don't clash with processes outside the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Code:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Running a Container with Host PID Namespace:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;This means the container shares the same "ticket numbers" as the host.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker run &lt;span class="nt"&gt;--pid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;host ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Running a Container with Isolated PID Namespace:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;This means the container has its own set of "ticket numbers" separate from the host.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker run &lt;span class="nt"&gt;--pid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;container ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the first example, the container interacts with processes as if it's in the same space as the host. In the second example, the container has its own isolated space for processes. It's like having a private area in a big event where your group has its own set of ticket numbers, allowing you to do things independently of the rest of the event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Containerization Concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Process ID Namespace:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Containers have their own isolated process ID (PID) space, so processes inside a container are separate from those outside.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker run &lt;span class="nt"&gt;--pid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;host ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - This command runs a container with the host's PID namespace, so it shares the same processes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Network Namespace:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Containers also have their own isolated network namespace, meaning they can have their own network configurations.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker run &lt;span class="nt"&gt;--net&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;host nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - This command runs a container with the host's network namespace.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unix Time Sharing Namespace:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This namespace allows containers to have their own view of time, separate from the host and other containers.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker run &lt;span class="nt"&gt;--uts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;host ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - This command runs a container with the host's Unix time sharing namespace.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;InterProcess Mount Namespace:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mount namespace isolates the file system, allowing containers to have their own file system view.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; docker run &lt;span class="nt"&gt;--mount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;bind&lt;/span&gt;,source&lt;span class="o"&gt;=&lt;/span&gt;/host/folder,target&lt;span class="o"&gt;=&lt;/span&gt;/container/folder ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - This command mounts a folder from the host into the container.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Certainly! Let's simplify the concept of cgroups:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cgroups:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;cgroups (short for control groups) help manage and distribute system resources, such as CPU and memory, among different processes or containers. They ensure that no single process or container uses up all the available resources, keeping everything balanced.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Code:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setting CPU Limit with Cgroups:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;This is like saying each guest at the party can only eat a certain amount of food.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker run &lt;span class="nt"&gt;--cpus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.5 ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;This limits the container to use only half of a CPU core.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setting Memory Limit with Cgroups:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;This is like saying each guest can only take up a certain amount of space on the dance floor.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker run &lt;span class="nt"&gt;--memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;100m ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;This limits the container to use only 100 megabytes of memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://docs.docker.com/engine/" rel="noopener noreferrer"&gt;Docker Engine overview&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/engine/api/" rel="noopener noreferrer"&gt;Develop with Docker Engine API&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.docker.com/config/containers/runmetrics/#control-groups" rel="noopener noreferrer"&gt;Runtime metrics&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The concept of Linux Containers and Windows Containers:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Linux Containers (Default):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Linux containers are a way to package and run software along with everything it needs, and they are most comfortable on computers that run Linux.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows Containers:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Windows containers are a way to package and run software, just like Linux containers, but they are designed to work on computers that run Windows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows Containers Basics:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Container Types:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows Containers come in two main types: Windows Server Core and Nano Server.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Windows Server Core:&lt;/strong&gt; Think of it as a more fully-featured container, suitable for a variety of applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nano Server:&lt;/strong&gt; Think of it as a lightweight container, designed for specific, minimalistic use cases.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Base Images:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Base images are like the blank canvas you start with when creating a container.

&lt;ul&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker pull mcr.microsoft.com/windows/servercore:ltsc2019
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   - This command pulls the Windows Server Core base image.

 - Example:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ```bash
   docker pull mcr.microsoft.com/windows/nanoserver:ltsc2019
   ```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   - This command pulls the Nano Server base image.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Supported Environments:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Windows Containers can run on specific versions of the Windows operating system.

&lt;ul&gt;
&lt;li&gt;Example:&lt;/li&gt;
&lt;li&gt;You can run Windows containers on Windows Server 2016.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - Example:
   - You can run Windows containers on Windows 10 Professional and Enterprise, with Hyper-V Isolated Containers for additional isolation.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Container orchestration
&lt;/h2&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%2F3lyleybojw3xmr2dgfep.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%2F3lyleybojw3xmr2dgfep.png" alt="Container orchestration" width="800" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;container orchestration is a way to manage and coordinate multiple containers, making sure they work together seamlessly to run applications, just like a super-smart manager making sure all the robots work together to build a perfect tower.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why orchestration?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Many Tasks, One Manager:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Imagine you have many robots (containers) doing different jobs. Orchestration is like having one super-smart manager (orchestrator) who tells each robot what to do and ensures everything happens smoothly.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Consistency:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Orchestration makes sure all tasks are done the same way every time. It's like having a set of instructions for your robots to follow, ensuring consistency in their actions.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Efficiency:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Orchestration helps optimize tasks, making sure resources (like time and materials) are used efficiently. It's like a manager making sure all robots work together without wasting energy.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scaling:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you need more work done, orchestration can easily create additional robots (containers). It's like magically summoning more robots to help when there's a lot to accomplish.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reliability:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Orchestration ensures that tasks are completed reliably, even if a robot (container) fails. It's like having a backup plan to make sure the job gets done no matter what.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Coordination:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Orchestration coordinates tasks, making sure robots work together seamlessly. It's like the manager making sure each robot knows its role and collaborates to achieve the overall goal.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Container Orchestration Code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a Docker service with 100 replicas (instances) of a Node.js application&lt;/span&gt;
docker service create &lt;span class="nt"&gt;--replicas&lt;/span&gt; 100 &lt;span class="nt"&gt;--name&lt;/span&gt; my-nodejs-app nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker service create&lt;/code&gt;: This command tells Docker to create a service, which is a group of running containers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--replicas 100&lt;/code&gt;: This flag specifies that you want 100 instances (replicas) of your service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--name my-nodejs-app&lt;/code&gt;: This flag gives a name to your service, in this case, "my-nodejs-app."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;nodejs&lt;/code&gt;: This is the image or recipe for your Node.js application. It's like the blueprint for baking cupcakes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, this simple code is like telling your magical chef's assistant (Docker Swarm) to create 100 replicas of your Node.js application, ensuring that you have a lot of containers running and ready to serve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Swarm
&lt;/h2&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%2Fz5noonjo2ikyrp90kc38.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%2Fz5noonjo2ikyrp90kc38.png" alt="Docker Swarm " width="800" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Docker Swarm is a tool that helps coordinate and manage a group of computers (nodes) to work together as a team of robots, allowing them to deploy and run multiple containers in a coordinated manner. It's like having a chief robot manager making sure all the individual robots build something big and amazing together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up Docker Swarm:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Swarm Manager:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Imagine you have a chief robot (Swarm Manager) that leads the team. The chief robot decides what needs to be done and directs the other robots (nodes) on how to work together.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="c"&gt;# Initiate Docker Swarm on the Swarm Manager&lt;/span&gt;
   docker swarm init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Node Worker:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Now, you have worker robots (Node Workers) ready to join the team. The Swarm Manager shares a special code (token) to invite them to work together.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="c"&gt;# Join a Node Worker to the Docker Swarm&lt;/span&gt;
   docker swarm &lt;span class="nb"&gt;join&lt;/span&gt; &lt;span class="nt"&gt;--token&lt;/span&gt; &amp;lt;token&amp;gt; &amp;lt;Swarm Manager IP&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Docker Swarm Service:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that you have a coordinated team, you want to create a service, like building towers with your robot team:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a Docker service (a group of containers) with 3 replicas (instances)&lt;/span&gt;
docker service create &lt;span class="nt"&gt;--replicas&lt;/span&gt; 3 &lt;span class="nt"&gt;--network&lt;/span&gt; frontend &lt;span class="nt"&gt;--name&lt;/span&gt; my-web-server my-web-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--replicas 3&lt;/code&gt;: This flag tells Docker to create three instances (replicas) of your service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--network frontend&lt;/code&gt;: This flag specifies that your service belongs to a network called "frontend."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--name my-web-server&lt;/code&gt;: This gives a name to your service, in this case, "my-web-server."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;my-web-image&lt;/code&gt;: This is the image or blueprint for your web server. It's like the recipe for building the towers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You set up your robot team with a chief (Swarm Manager) and worker robots (Node Workers). Then, you instruct them to build a service (group of containers) that runs your web server application. The chief robot ensures that three replicas of your web server are created and connected to the "frontend" network. It's like having a chief robot manager overseeing the construction of multiple towers (containers) with the help of the worker robots.&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%2Fytitz2wt4jsufejox9yx.gif" 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%2Fytitz2wt4jsufejox9yx.gif" alt="Image description" width="498" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>docker</category>
      <category>webdev</category>
      <category>devops</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Decoding the Cyber Threat Landscape: Exploring Different Types of Cyber Attacks</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Wed, 13 Dec 2023 03:36:53 +0000</pubDate>
      <link>https://forem.com/abhixsh/different-types-of-cyber-attacks-6j9</link>
      <guid>https://forem.com/abhixsh/different-types-of-cyber-attacks-6j9</guid>
      <description>&lt;h2&gt;
  
  
  INTRODUCTION
&lt;/h2&gt;

&lt;p&gt;Technology has led to an interconnected world everywhere but has also created cyber threats that pose significant risks. This report examines various cyber-attacks, their methods, and impacts. By understanding these attacks, users can develop strategies to strengthen cyber defenses.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;" There are only two types of organizations: Those that have been hacked and those that don’t know it yet! "&lt;br&gt;
John T. Chambers Former CEO of Cisco Systems&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  COMMON CYBERATTACKS
&lt;/h2&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%2Fc1oxpc5u91u08r8ofv7a.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%2Fc1oxpc5u91u08r8ofv7a.png" alt="Figure 01: Common Cyberattacks" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. Ransomware Attacks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ransomware attacks have emerged as a formidable threat. These malicious attacks often use cunning methods to infiltrate systems through deceptive emails, websites, or vulnerable software.&lt;br&gt;
Once inside, ransomware quickly encrypts essential files, usually holding them hostage until a ransom is paid in cryptocurrency. It causes business disruptions, data loss, and financial setbacks. Compromising or resisting the attackers' demands is challenging. Robust backup strategies, regular updates, and proactive cybersecurity measures are critical to mitigating the effects of ransomware.&lt;/p&gt;

&lt;p&gt;Ransomware attacks, explained &lt;a href="https://www.youtube.com/watch?v=eyyogKy3tW0&amp;amp;ab_channel=CNN" rel="noopener noreferrer"&gt;[Video]&lt;/a&gt;&lt;br&gt;
What is a Ransomware Attack? &lt;a href="https://www.imperva.com/learn/application-security/ransomware/" rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. Phishing Attacks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Phishing is a cunning cyber strategy—attempts to steal sensitive data by masquerading as trusted companies. Attackers trick victims into revealing crucial information. Mainly, they use tactics like email or instant messaging, advanced fee scams, account deactivation cons, and fake websites.&lt;br&gt;
Two specific forms stand out in phishing: spear phishing and clone phishing. Spear phishing targets specific individuals or companies, using phishing messages with personalized details, changing emails, links, or files to look legitimate, and redirecting victims to malicious sites or content. For attacks on high-level executives, using deceptive emails to obtain critical actions or funding is central. Vigilance is the primary method to strengthen against this digital menace.&lt;/p&gt;

&lt;p&gt;What is Phishing &lt;a href="https://www.youtube.com/watch?v=gWGhUdHItto&amp;amp;ab_channel=IBMTechnology" rel="noopener noreferrer"&gt;[Video]&lt;/a&gt;&lt;br&gt;
Phishing attacks &lt;a href="https://www.imperva.com/learn/application-security/phishing-attack-scam/" rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. Virus&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Computer viruses pose as stealthy intrusions designed to disrupt. These malicious codes use various methods to infect your device, often running innocent-looking files, downloads, or even emails. Once inside, they replicate and spread like a virtual contagion, damaging the integrity of your system.&lt;br&gt;
Viruses can manifest in many forms, from the infamous ransomware that demands a ransom for your files to rogue Trojan horses that hide inside seemingly harmless programs. Their effects are far-reaching, including system slowdowns, data corruption, and, in extreme cases, turning off your device.&lt;br&gt;
Protecting yourself from these digital bandits requires a vigilant approach. Regular software updates, vital anti-virus programs, and a healthy dose of unexpected emails or downloads act as your virtual armor.&lt;/p&gt;

&lt;p&gt;What are Computer Viruses &lt;a href="https://www.youtube.com/watch?v=1-LdzEuAyiY&amp;amp;ab_channel=SimplyExplained-English" rel="noopener noreferrer"&gt;[video]&lt;/a&gt;&lt;br&gt;
Virus &lt;a href="https://www.techtarget.com/searchsecurity/definition/virus" rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D. SpyWare&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Spyware are silent intruders. These stealthy programs, often undetected, sneak into your device with a singular mission – to surreptitiously track your every digital move.&lt;br&gt;
Spyware uses sneaky methods, running on seemingly harmless downloads or masquerading as freeware. Once embedded, it secretly collects – from passwords – browsing history and sensitive information and sends it to a remote server.&lt;br&gt;
Spyware's effects are as insidious as its methods. It can lead to compromised privacy, identity theft, and financial loss. Identifying and combating these digital spies requires a vigilant approach with regular system scans, robust cybersecurity software, and careful browsing habits.&lt;/p&gt;

&lt;p&gt;What is Spyware? &lt;a href="https://www.youtube.com/watch?v=-Z3pp14oUiA&amp;amp;ab_channel=Kaspersky" rel="noopener noreferrer"&gt;[Video]&lt;/a&gt;&lt;br&gt;
All about spyware &lt;a href="https://www.malwarebytes.com/spyware" rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ADVANCED PERSISTENT THREATS (APTS)
&lt;/h2&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%2Fywiqpl7fhm49f1qf87k2.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%2Fywiqpl7fhm49f1qf87k2.png" alt="Figure 02: Advanced persistent threats" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. Definition and Characteristics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Advanced Persistent Threats (APTs) represent a complex category of cyberattacks orchestrated by well-funded and organized entities. These attacks are notable for their persistence, stealth, and advanced nature. Unlike most common cyber threats, APTs are not opportunistic; they are meticulously planned and implemented over a long period. APT actors often have significant resources, including financial backing, advanced technical capabilities, and a deep understanding of their targets.&lt;br&gt;
The characteristics of APTs make them particularly challenging for traditional cybersecurity measures to detect and mitigate. Their persistence allows them to remain undetected for long periods, continuously adapting to security measures. Stealth is key, as APTs are designed to avoid alerts and operate silently in the target environment. The advanced nature of these attacks involves using sophisticated techniques, which are highly effective and difficult to counter.&lt;br&gt;
As defenders, understanding the nuances of APTs is critical to developing effective defense strategies. Recognizing that these attacks go beyond the scope of general cyber threats enables organizations to tailor their cyber security measures to meet the specific challenges posed by APTs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. Tactics, Techniques and Procedures (TTPs)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;APTs use a variety of Tactics, Techniques, and Procedures (TTPs) to achieve their goals—these range from exploiting zero-day vulnerabilities to using sophisticated social engineering tactics. A zero-day vulnerability is a previously unknown software bug that attackers exploit before the software vendor becomes aware and patches. Social engineering involves manipulating people into revealing sensitive information or taking actions that could compromise security.&lt;br&gt;
Understanding APT TTPs is essential for organizations to develop effective defenses against these sophisticated attacks. Some common APT tactics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero-day exploits:&lt;/strong&gt; APTs often use undisclosed vulnerabilities in software to gain unauthorized access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social Engineering:&lt;/strong&gt; APT actors manipulate individuals through deceptive tactics to gather information or gain access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom-made malware:&lt;/strong&gt; APTs create specialized malware tailored to the target environment, making it difficult to detect.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Insider Threats:&lt;/strong&gt; AAPTs can use insiders within an organization to facilitate their attacks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By understanding the specific tactics used by APTs, organizations can improve their threat detection capabilities and implement countermeasures tailored to the unique challenges posed by these advanced attacks. This understanding allows for a more proactive and adaptive cyber security posture, critical to mitigating the risks associated with APTs.&lt;/p&gt;

&lt;p&gt;Advanced Persistent Threat &lt;a href="https://www.youtube.com/watch?v=Gin4PUi0wYc&amp;amp;ab_channel=Udacity" rel="noopener noreferrer"&gt;[Video]&lt;/a&gt;&lt;br&gt;
What is an advanced persistent threat (APT)? &lt;a href="https://www.techtarget.com/searchsecurity/definition/advanced-persistent-threat-APT" rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  INSIDER THREATS
&lt;/h2&gt;

&lt;p&gt;Insider threats represent a significant risk to organizations as individuals with privileged access can intentionally or unintentionally destroy sensitive information. These insiders may include employees, contractors, or business partners with access to critical systems or data. Insider threats are diverse and can manifest in many ways, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Espionage:&lt;/strong&gt; Insiders may intentionally collect and share sensitive information with outside entities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Theft:&lt;/strong&gt; Insiders can steal valuable data for personal gain or sell it on the black market.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Malicious Activities:&lt;/strong&gt; Disgruntled employees may engage in activities that harm the organization, such as deleting critical data or disrupting operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mitigating insider threats requires a multifaceted approach that combines technical solutions with corporate policies and a cybersecurity-aware culture. Robust access controls play a key role in limiting people's access to only the information necessary for their roles, reducing the potential impact of insider threats.&lt;br&gt;
Creating a cybersecurity-aware culture within an organization involves educating employees about the risks associated with insider threats and promoting a sense of responsibility for protecting sensitive information. Regular training programs help employees identify and report suspicious activity, creating a collaborative effort to maintain a safe environment.&lt;br&gt;
Implementing user activity monitoring tools can help identify unusual or malicious behavior by insiders. Organizations can identify anomalies that may indicate a threat by analyzing access patterns and data usage. Additionally, establishing clear incident response plans ensures that organizations can respond quickly and effectively in the event of an insider threat incident.&lt;br&gt;
Ultimately, maintaining a secure and resilient cybersecurity posture requires identifying potential risks posed by insider threats and implementing proactive measures to mitigate these risks.&lt;/p&gt;

&lt;p&gt;Defining Insider Threats &lt;a href="https://www.cisa.gov/topics/physical-security/insider-threat-mitigation/defining-insider-threats" rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;br&gt;
What Is an Insider Threat &lt;a href="https://www.imperva.com/learn/application-security/insider-threats/" rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;br&gt;
The Insider Threat | Security Detail &lt;a href="https://www.youtube.com/watch?v=5bEZbFxSJYM&amp;amp;ab_channel=RedHat" rel="noopener noreferrer"&gt;[Video]&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  DISTRIBUTED DENIAL OF SERVICE (DDOS) ATTACKS
&lt;/h2&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%2Fty0izmhlgigem8649s3u.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%2Fty0izmhlgigem8649s3u.png" alt="Figure 03: Distributed Denial of Service" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Distributed Denial of Service (DDoS) attacks aim to overwhelm a target's online services by flooding them with heavy traffic. These attacks disrupt the regular operation of the targeted system or network, making it inaccessible to legitimate users. DDoS attacks can have dire consequences for businesses, from financial loss to affecting the availability of critical online services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. Mitigation Strategies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Network Monitoring:&lt;/strong&gt; Regular monitoring of network traffic patterns can help detect early signs of a DDoS attack. Anomalies, such as a sudden increase in incoming traffic, can trigger alerts for immediate investigation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traffic Filtering:&lt;/strong&gt; Implementing traffic filtering mechanisms helps distinguish legitimate traffic from malicious traffic. This includes blocking or limiting the impact of malicious requests while allowing legitimate users to access the Services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dedicated DDoS Mitigation Tools:&lt;/strong&gt; Dedicated DDoS mitigation tools and services can provide advanced capabilities to detect and mitigate DDoS attacks. These tools often use a combination of traffic analysis, behavioral analytics, and machine learning to distinguish between legitimate and malicious traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content Delivery Networks (CDNs):&lt;/strong&gt; CDNs can distribute a load of incoming traffic across multiple servers, making it harder for attackers to bypass a single target. CDNs can absorb a significant portion of DDoS traffic, ensuring that targeted services remain accessible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalable Infrastructure:&lt;/strong&gt; Ensuring that the infrastructure supporting online services is scalable allows it to absorb more traffic during a DDoS attack. Scalability enables the organization to maintain service availability even under heavy load.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Response Planning:&lt;/strong&gt; Developing and regularly testing incident response plans specific to DDoS attacks ensures that organizations can respond quickly and effectively. This may include coordination with DDoS mitigation service providers and law enforcement, depending on the severity of the attack.&lt;/li&gt;
&lt;/ul&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%2Fb4cis97xkq2s7euzqfzj.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%2Fb4cis97xkq2s7euzqfzj.png" alt="figure 05: DDOS Attacks" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Organizations must combine these mitigation strategies to improve their resilience against DDoS attacks. As DDoS attack methods continue to evolve, staying aware of emerging threats and updating mitigation strategies accordingly is critical to maintaining effective cybersecurity defenses.&lt;/p&gt;

&lt;p&gt;Distributed Denial of Service (DDoS) &lt;a href="https://www.imperva.com/learn/ddos/denial-of-service/" rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;br&gt;
What is a DDoS attack? &lt;a href="https://www.cloudflare.com/learning/ddos/what-is-a-ddos-attack/#:~:text=A%20distributed%20denial%2Dof%2Dservice%20(DDoS)%20attack%20is,a%20flood%20of%20Internet%20traffic." rel="noopener noreferrer"&gt;[Article]&lt;/a&gt;&lt;br&gt;
Distributed denial of service attacks &lt;a href="https://www.researchgate.net/publication/3876432_Distributed_denial_of_service_attacks" rel="noopener noreferrer"&gt;[Research]&lt;/a&gt;&lt;br&gt;
Denial of Service Attacks Explained &lt;a href="https://www.youtube.com/watch?v=bDAY-oUP0DQ&amp;amp;ab_channel=IBMTechnology" rel="noopener noreferrer"&gt;[Video]&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  EMERGING THREATS
&lt;/h2&gt;

&lt;p&gt;As technology evolves, new threats are emerging, requiring a proactive approach and continuous research to stay ahead of previous risks. Some emerging threats that organizations need to be vigilant about include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Artificial Intelligence (AI) and Machine Learning (ML) Attacks:&lt;/strong&gt; Adversaries can use AI and ML to improve the sophistication of their attacks, making them more adaptive and evasive. Defenders must use advanced AI and ML techniques to identify and mitigate threats.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;5G Security Challenges:&lt;/strong&gt; The rollout of 5G technology introduces new security challenges, including increased attack surfaces and the potential for more sophisticated attacks. Organizations must adapt their cybersecurity measures to address the unique risks associated with 5G networks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Internet of Things (IoT) Vulnerabilities:&lt;/strong&gt; : The proliferation of IoT devices creates additional entry points for cyber-attacks. Securing IoT devices and networks is critical to preventing unauthorized access and potential exploitation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quantum Computing Threats:&lt;/strong&gt; Advances in quantum computing may threaten traditional encryption methods. Organizations need to explore and adopt quantum-resistant cryptographic algorithms to ensure the continued security of their data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cyber-Physical Attacks:&lt;/strong&gt; The convergence of digital and physical systems introduces the risk of cyber-physical attacks, where adversaries can manipulate digital and physical components. Defenders must implement measures to secure cyber-physical systems effectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CONCLUSION
&lt;/h2&gt;

&lt;p&gt;This detailed analysis underscores the complex nature of contemporary cyber security practices and the variety of cyber threats organizations face. Given the dynamic and evolving tactics malicious actors use, they require multiple cybersecurity approaches.&lt;br&gt;
Collaboration among stakeholders, including government agencies, private enterprises, and the cybersecurity community, is essential to strengthening defenses against cyber threats' pervasive and ever-changing nature. As the digital world continues to evolve, a proactive stance, continuous research, and adaptive security measures are critical to staying ahead of emerging threats and ensuring a resilient cybersecurity posture. Organizations must remain vigilant, invest in cybersecurity education and training, and embrace innovative technologies to protect their digital assets and infrastructure from the evolving threat landscape.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
This is my university Information Assurance subject assignment article. I am Aloka Abishek Haththakage, Department of Information and Communication Technology, Uva Wellassa University.&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>cybersecurity</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Hacktoberfest 2023: Celebrating the Last Days- My Rewards and Your Opportunity to Shine</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Sun, 29 Oct 2023 17:44:07 +0000</pubDate>
      <link>https://forem.com/abhixsh/hacktoberfest-2023-celebrating-the-last-days-my-rewards-and-your-opportunity-to-shine-gim</link>
      <guid>https://forem.com/abhixsh/hacktoberfest-2023-celebrating-the-last-days-my-rewards-and-your-opportunity-to-shine-gim</guid>
      <description>&lt;p&gt;As we approach the final week of Hacktoberfest 2023, the open-source community is buzzing with excitement. This past month has seen incredible contributions, collaborations, and a shared commitment to sustainability. In this article, I'm thrilled to share my own success story, hoping to inspire you to embark on your Hacktoberfest journey if you haven't already. Remember, the rewards and impact extend far beyond the code you contribute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/abhixsh" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Hello, I'm Abishek Haththakage, a DevOps enthusiastic undergraduate student with a strong passion for computer science. My tech journey began in my childhood and has been an exhilarating ride ever since. In this blog, I'll take you through my experiences, challenges, and growth during my participation in Hacktoberfest, an event that profoundly impacted me.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hacktoberfest: My First Taste of Open Source
&lt;/h3&gt;

&lt;p&gt;In the midst of my programming adventures, I stumbled upon Hacktoberfest, an annual event that celebrates open-source contributions. I decided to take the plunge and participate. Little did I know that this would be a turning point in my journey.&lt;/p&gt;

&lt;h3&gt;
  
  
  Highs and Lows: My Hacktoberfest Experience
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://holopin.io/@abhixsh" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fholopin.me%2Fabhixsh" alt="An image of @abhixsh's Holopin badges, which is a link to view their full Holopin profile" width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Participating in Hacktoberfest was an exhilarating experience. I embarked on my open-source journey, ready to make a meaningful contribution to the tech community. However, it wasn't all smooth sailing. I encountered several challenges, such as:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting Started with New Projects:&lt;/strong&gt; The process of getting started with new open-source projects can be overwhelming. Navigating through the codebase, understanding the project's goals, and identifying issues to work on was initially daunting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Working Processes:&lt;/strong&gt; Each open-source project has its own set of working processes and guidelines. Adapting to these processes and ensuring that my contributions adhered to their standards required time and effort.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overcoming Challenges: A Steep Learning Curve&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Despite the initial hurdles, I was determined to overcome these challenges. With perseverance and a proactive approach, I started making progress. I sought guidance from experienced contributors and tapped into the collective wisdom of the open-source community. It was heartening to see the supportive and collaborative nature of this community.&lt;/p&gt;

&lt;p&gt;By the end of Hacktoberfest, I had successfully made Eight contributions. These contributions ranged from bug fixes to new feature implementations, and each one was a valuable learning experience. I had come a long way from where I started, and the journey was far from over.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Tree-Planting Reward:&lt;/strong&gt; A Symbol of Environmental Responsibility&lt;br&gt;
This year, Hacktoberfest made a bold move toward sustainability by replacing the beloved t-shirt rewards with digital reward kits. But it didn't end there. In the spirit of environmental responsibility, Hacktoberfest initiated a tree-planting program. Each time I completed my first pull/merge request, a tree was planted as part of the Usambara Biodiversity Conservation project in Tanzania. It's a tangible way for the tech community to give back to the environment and contribute to reforesting our planet.&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%2F1zdr4zy8nqc8za57n7y6.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%2F1zdr4zy8nqc8za57n7y6.png" alt="Image description" width="607" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Growth and Future Endeavors
&lt;/h2&gt;

&lt;p&gt;Participating in Hacktoberfest opened my eyes to the incredible world of open source. I gained a profound understanding of how GitHub works, the importance of version control, and the significance of collaboration in building innovative solutions. I also developed skills in effective communication, problem-solving, and project management.&lt;/p&gt;

&lt;p&gt;My experiences during Hacktoberfest have inspired me to continue contributing to open-source projects. I'm excited to dive deeper into the open-source world, explore new technologies, and collaborate with fellow tech enthusiasts.&lt;/p&gt;

&lt;p&gt;Repos Beginners can contribute :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/shivaylamba/Hacktoberfest" rel="noopener noreferrer"&gt;Hacktoberfest&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/Sangwan5688/Hacktoberfest2021" rel="noopener noreferrer"&gt;Hacktoberfest2021&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/tarunsinghofficial/HacktoberFest" rel="noopener noreferrer"&gt;HacktoberFest&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/ossamamehmood/Hacktoberfest" rel="noopener noreferrer"&gt;Hacktoberfest&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>hack23contributor</category>
      <category>hacktoberfest</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Hacktoberfest 2023: A Digital Swag Revolution for Open-Source Enthusiasts</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Sun, 29 Oct 2023 14:29:06 +0000</pubDate>
      <link>https://forem.com/abhixsh/hacktoberfest-2023-a-digital-swag-revolution-for-open-source-enthusiasts-1i69</link>
      <guid>https://forem.com/abhixsh/hacktoberfest-2023-a-digital-swag-revolution-for-open-source-enthusiasts-1i69</guid>
      <description>&lt;p&gt;Hacktoberfest is an annual event that encourages people to contribute to open-source projects on platforms like GitHub. It usually takes place throughout the month of October. Participants are required to make a certain number of pull requests (code contributions) to open-source repositories to earn a limited-edition Hacktoberfest t-shirt or other rewards. It's a fun way for people to get involved in the open-source community, learn and improve their coding skills, and give back to the software development community.&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%2Fzsak7ikpxke77uvmm3v5.jpg" 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%2Fzsak7ikpxke77uvmm3v5.jpg" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Is Hacktoberfest So Popular?
&lt;/h1&gt;

&lt;p&gt;Hacktoberfest is super popular because it makes open-source coding easy and fun. People of all coding levels can join in, from beginners to pros. You help out on cool projects, and in return, you get rewards like a special t-shirt. It's a big yearly event that connects coders from all around the world. You can learn and make friends, and it's really simple to get started - just have an internet connection, a GitHub account, and a desire to learn and help. This mix of inclusivity, learning, and free stuff makes Hacktoberfest a favourite among coders.&lt;/p&gt;

&lt;h1&gt;
  
  
  Hacktoberfest 2023: A Digital Swag Revolution
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://holopin.io/@abhixsh" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fholopin.me%2Fabhixsh" alt="An image of @abhixsh's Holopin badges, which is a link to view their full Holopin profile" width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hacktoberfest swags, or goodies, are a key attraction for many participants in the annual event. These swags are incentives offered to individuals who complete the Hacktoberfest challenge, which typically involves making a specific number of contributions to open-source repositories on platforms like GitHub during the month of October. The swag items vary from year to year but often include a limited-edition Hacktoberfest t-shirt, stickers, and sometimes other exclusive merchandise like hoodies, laptop decals, or even small gadgets. These items are not only cool to have but also serve as badges of honour and reminders of one's contributions to the open-source community. They help create a sense of belonging and reward contributors for their efforts, further motivating people to participate in Hacktoberfest and support open source.&lt;/p&gt;

&lt;p&gt;In its tenth year, Hacktoberfest is changing things up for the future. Instead of giving out t-shirts, they're now offering digital rewards. T-shirt production and shipping had gotten really hard, and it was costly. People in some countries even had to pay a lot for customs taxes. But Hacktoberfest is still all about supporting open-source projects. Now, they're working with Holopin to offer a digital reward kit. It has cool customizable badges that show your journey in open source. You can also win special badges and gifts. And if you succeed, you can share your badge on the Holopin Hacktoberfest Badge Board of Fame. Plus, they're planting a tree for the first 50,000 people who complete their first pull/merge request this year, instead of giving out t-shirts.&lt;/p&gt;

&lt;h1&gt;
  
  
  Exciting Rewards for Hacktoberfest 2023
&lt;/h1&gt;

&lt;p&gt;Hacktoberfest 2023 Reward Kit offers various rewards to participants who complete the event.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rewards include:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Amplication:&lt;/strong&gt; Free Amplication Pro Plan for two months and other gifts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Appwrite:&lt;/strong&gt; $50 in Appwrite Cloud Credits, valid for 90 days.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DagsHub:&lt;/strong&gt; A 1-month free trial of the Team tier, including up to 1TB of storage, data and notebook versioning CI/CD/CT integration, and up to 5 Annotation projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DEV:&lt;/strong&gt; Earn dev.to badges for contributions, gain community recognition, and receive discounts for the Form Shop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DigitalOcean:&lt;/strong&gt; $200 in Credits, valid for 60 days.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; GitHub's Student Developer Pack offers verified students thousands of dollars worth of tools for free.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hacktoberfest:&lt;/strong&gt; Participants can get featured in the 2023 Hall of Fame.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Holopin:&lt;/strong&gt; One month free of the Holopin Starter Plan to create and issue 1 badge for up to 100 recipients.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hugging Face:&lt;/strong&gt; An exclusive Hugging Face badge and access to an organization that provides early access to new features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ILLA:&lt;/strong&gt; Redeem two months of free access to ILLA Cloud Premium, or 80% off for 6 months.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MLH:&lt;/strong&gt; Claim a special Holopin digital badge to celebrate Open Source and MLH Global Hack Week, with some additional special perks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenSauced:&lt;/strong&gt; 12 months of free access to all OpenSauced's paid features, and the chance to connect with other contributors and maintainers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From my experience at Hacktoberfest.Hacktoberfest is a fantastic event with benefits. It lets you learn and grow your coding skills by contributing to open-source projects. You can make new friends and professional connections in the tech world. Plus, you're giving back to the community by improving open-source software. And don't forget the cool swag you can earn! So, it's a win-win for everyone involved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hacktoberfest.com/" rel="noopener noreferrer"&gt;Official Hacktoberfest Website&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.blog/" rel="noopener noreferrer"&gt;GitHub's Blog&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.digitalocean.com/community/tutorials" rel="noopener noreferrer"&gt;DigitalOcean's Blog &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%2F9papi2v1n1q093g7xeka.gif" 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%2F9papi2v1n1q093g7xeka.gif" alt="Image description" width="320" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>hacktoberfest23</category>
      <category>hacktoberfest</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Streamlining the User Experience: Enhancing the Admin Panel for Seamless Management</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Wed, 19 Jul 2023 17:06:19 +0000</pubDate>
      <link>https://forem.com/abhixsh/streamlining-the-user-experience-enhancing-the-admin-panel-for-seamless-management-2djl</link>
      <guid>https://forem.com/abhixsh/streamlining-the-user-experience-enhancing-the-admin-panel-for-seamless-management-2djl</guid>
      <description>&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;I built a Refine Admin Panel that serves as a comprehensive tool for managing and organizing data. It provides various features and functionality to streamline the data management process and increase productivity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category Submission:
&lt;/h3&gt;

&lt;p&gt;Project built using Supabase as the main data provider for the refine app and Project built using Material UI.&lt;/p&gt;

&lt;h3&gt;
  
  
  App Link
&lt;/h3&gt;

&lt;p&gt;The app is hosted via Netlify. &lt;a href="https://warm-custard-2be6df.netlify.app/" rel="noopener noreferrer"&gt;LINK&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&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%2Feeytjjrmwqzgt958h7jg.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%2Feeytjjrmwqzgt958h7jg.png" alt="Image description" width="800" height="450"&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%2Fxwbu4oa42ojb833t71vp.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%2Fxwbu4oa42ojb833t71vp.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;

&lt;p&gt;Refine Admin Panel is a user-friendly web application that provides an intuitive interface for managing and refining data. It is designed to simplify complex data management tasks and increase efficiency. Key features of the Refine Admin Panel include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Import/Export:&lt;/strong&gt; Easily import and export data in various formats like CSV, Excel, JSON.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Visualization:&lt;/strong&gt; Generate visual representations of data using charts, graphs and other visualization techniques to facilitate understanding and decision making.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Filtering and Sorting:&lt;/strong&gt; Filter and sort data based on specific criteria to locate and analyze information more effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bulk Operations:&lt;/strong&gt; Perform bulk operations on data, such as editing multiple records at once, deleting selected data, or applying changes to a subset of data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Management:&lt;/strong&gt; Manage user accounts, access levels and permissions to ensure secure and controlled access to the admin panel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Customization:&lt;/strong&gt; Customize the look and layout of the admin panel to suit your preferences and branding needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automation and Integration:&lt;/strong&gt; Integrate the refined admin panel with other systems or workflows using APIs or webhooks to automate data processing tasks and streamline operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Link to Source Code
&lt;/h3&gt;

&lt;p&gt;The app's source code is accessible on GitHub: &lt;a href="https://github.com/abhixsh/Blog-logging-panel-refine" rel="noopener noreferrer"&gt;https://github.com/abhixsh/Blog-logging-panel-refine&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Permissive License
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://github.com/abhixsh/Blog-logging-panel-refine/blob/master/LICENSE" rel="noopener noreferrer"&gt;MIT&lt;/a&gt; license, a liberal free software license, governs the use of the application. This indicates that there are no restrictions on how the software may be used, updated, or distributed, including for commercial reasons.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background (What made you decide to build this particular app? What inspired you?)
&lt;/h2&gt;

&lt;p&gt;The decision to build this particular application was primarily driven by the desire to learn and gain hands-on experience in performing CRUD (Create, Read, Update, Delete) operations in web development. CRUD operations are the core functionalities that are widely used in various applications and are the backbone of many software systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  How I built it (How did you utilize refine? Did you learn something new along the way? Pick up a new skill?)
&lt;/h3&gt;

&lt;p&gt;Learned a lot about Refine. Refine, also known as OpenRefine, is a powerful open-source tool for data cleaning, transformation, and exploration. It provides a user-friendly interface and a range of features that help users improve the quality and consistency of their data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Resources/Info
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://refine.dev/docs/tutorial/introduction/index/" rel="noopener noreferrer"&gt;refine tutorial for building a complete CRUD app.&lt;/a&gt;&lt;br&gt;
&lt;a href="https://refine.dev/docs/" rel="noopener noreferrer"&gt;refine official documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>refine</category>
      <category>refinehackathon</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Comprehensive Beginner's Guide to NPM: Simplifying Package Management</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Fri, 14 Jul 2023 02:00:46 +0000</pubDate>
      <link>https://forem.com/abhixsh/a-comprehensive-beginners-guide-to-npm-simplifying-package-management-57l5</link>
      <guid>https://forem.com/abhixsh/a-comprehensive-beginners-guide-to-npm-simplifying-package-management-57l5</guid>
      <description>&lt;p&gt;In the vast landscape of web development, efficiently managing project dependencies is crucial for seamless development workflows. Enter NPM (Node Package Manager), a robust package manager designed for JavaScript projects, primarily used in conjunction with Node.js. This fully beginner-friendly guide will take you through the fundamentals of NPM, providing you with a solid foundation for simplifying package management and streamlining your development process.&lt;/p&gt;

&lt;p&gt;NPM is a command-line tool that facilitates the installation, management, and sharing of reusable JavaScript code modules, known as packages, within your projects. As the default package manager for Node.js, NPM comes bundled with the Node.js installation, making it readily available.&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%2F4dr1l24q8a8e601ar3bp.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%2F4dr1l24q8a8e601ar3bp.png" alt="Image description" width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing NPM:
&lt;/h2&gt;

&lt;p&gt;Before diving into NPM, you'll need to have Node.js installed on your system. Simply head over to the official Node.js website (nodejs.org) and download the appropriate version for your operating system. Once Node.js is successfully installed, NPM will be at your fingertips through your command prompt or terminal.&lt;/p&gt;

&lt;p&gt;And also, npm includes a CLI (Command Line Client) that can be used to download and install the software:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows Example&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;C:\&amp;gt;npm install &amp;lt;package&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mac OS Example&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;gt;npm install &amp;lt;package&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Here are some beginner-level NPM commands:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm init&lt;/code&gt;&lt;br&gt;
This command initializes a new NPM package within your project directory. It creates a &lt;code&gt;package.json&lt;/code&gt; file, where you can define project metadata, dependencies, and other configurations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm install &amp;lt;package-name&amp;gt;&lt;/code&gt;&lt;br&gt;
This command installs a specific NPM package and its dependencies into your project. Replace &lt;code&gt;&amp;lt;package-name&amp;gt;&lt;/code&gt; with the name of the package you want to install. The package and its dependencies will be downloaded and saved in the &lt;code&gt;node_modules&lt;/code&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm install&lt;/code&gt;&lt;br&gt;
Running &lt;code&gt;npm install&lt;/code&gt; without specifying a package name will install all the dependencies listed in the &lt;code&gt;package.json&lt;/code&gt; file. It ensures that all required packages for your project are installed and up to date.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm uninstall &amp;lt;package-name&amp;gt;&lt;/code&gt;&lt;br&gt;
This command removes a specific NPM package from your project. Replace &lt;code&gt;&amp;lt;package-name&amp;gt;&lt;/code&gt; with the name of the package you want to uninstall. The package and its associated files will be removed from the &lt;code&gt;node_modules&lt;/code&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm update&lt;/code&gt;&lt;br&gt;
Running &lt;code&gt;npm update&lt;/code&gt; updates all the packages listed in the &lt;code&gt;package.json&lt;/code&gt; file to their latest versions. It checks for new versions of packages and updates them accordingly. It's important to test your code after running this command to ensure compatibility with the updated packages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm outdated&lt;/code&gt;&lt;br&gt;
The &lt;code&gt;npm outdated&lt;/code&gt; command displays a list of installed packages that have newer versions available. It helps you identify which packages are outdated and need to be updated to their latest versions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm run &amp;lt;script-name&amp;gt;&lt;/code&gt;&lt;br&gt;
NPM allows you to define custom scripts in the &lt;code&gt;scripts&lt;/code&gt; section of your &lt;code&gt;package.json&lt;/code&gt; file. The &lt;code&gt;npm run &amp;lt;script-name&amp;gt;&lt;/code&gt; command executes a specific script defined in the &lt;code&gt;package.json&lt;/code&gt; file. Replace &lt;code&gt;&amp;lt;script-name&amp;gt;&lt;/code&gt; with the name of the script you want to run.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm publish&lt;/code&gt;&lt;br&gt;
If you have developed a package and want to make it available to others, the &lt;code&gt;npm publish&lt;/code&gt; command helps you publish your package to the NPM registry. It allows other developers to install and use your package in their projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can See a simple &lt;strong&gt;NPM Basics Cheat Sheet&lt;/strong&gt; through this &lt;a href="https://devhints.io/npm" rel="noopener noreferrer"&gt;link&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%2Fytinfzj5hct36bj3uyy8.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%2Fytinfzj5hct36bj3uyy8.png" alt="Image description" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Free Courses :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=cjoTTSbOuG0&amp;amp;t=28s&amp;amp;ab_channel=codedamn" rel="noopener noreferrer"&gt;NPM Full Course For Beginners - Learn NPM fundamentals and basics&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/learning/node-js-essential-training-web-servers-tests-and-deployment-18647002/going-beyond-the-basics-in-node" rel="noopener noreferrer"&gt;Node.js Essential Training: Web Servers, Tests, and Deployment&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  There are some additional points.
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Managing Dependencies:&lt;/strong&gt;&lt;br&gt;
NPM simplifies dependency management by allowing you to specify desired package versions and ranges directly within the package.json file. With this approach, NPM ensures that all required packages are installed correctly, thereby avoiding version conflicts and ensuring the stability of your project. To update or remove packages, NPM provides dedicated commands like npm update or npm uninstall, further streamlining the management process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unleashing the Power of NPM Scripts:&lt;/strong&gt;&lt;br&gt;
NPM Scripts are a powerful feature that empowers developers to define custom scripts within the package.json file. These scripts can be easily executed via the command line, using the npm run  syntax. By harnessing NPM Scripts, you can automate a wide range of tasks, such as running tests, building your project, or deploying to a server, greatly enhancing your development workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Publishing Your Packages:&lt;/strong&gt;&lt;br&gt;
NPM goes beyond consuming packages and enables developers to publish their packages to the NPM registry, thereby contributing to the vibrant JavaScript ecosystem. By creating an account on the NPM website and following a few straightforward steps, you can share your code with the community, receive feedback, and make your mark within the development community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introducing the Package.json File:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the core of every NPM project lies the essential "package.json" file. This file acts as the project's manifesto, housing crucial metadata such as the project name, version, dependencies, and other essential configurations. You can manually create a package.json file or generate one effortlessly by executing the npm init command within your project directory.&lt;/p&gt;

&lt;p&gt;NPM serves as a robust and indispensable tool for simplifying package management within JavaScript projects. By familiarizing yourself with NPM's fundamentals, you gain the ability to effortlessly install, manage, and share packages, ultimately improving your development workflow. Armed with this knowledge, you can harness the benefits of NPM to create efficient and maintainable projects, all while enhancing your web development skill set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional resources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;NPM website: &lt;a href="https://www.npmjs.com/" rel="noopener noreferrer"&gt;https://www.npmjs.com/&lt;/a&gt;&lt;br&gt;
NPM documentation: &lt;a href="https://docs.npmjs.com/" rel="noopener noreferrer"&gt;https://docs.npmjs.com/&lt;/a&gt;&lt;br&gt;
Node.js website: &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;https://nodejs.org/en/&lt;/a&gt;&lt;br&gt;
JavaScript tutorial: &lt;a href="https://www.w3schools.com/js/" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/&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%2F30ip7varncekccdegtk9.gif" 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%2F30ip7varncekccdegtk9.gif" alt="Image description" width="356" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, that’s it for this article.&lt;/strong&gt;&lt;br&gt;
Also, if you have any questions about this or anything else, please feel free to let me know in a comment below or on &lt;a href="https://www.instagram.com/_abhixsh/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; , &lt;a href="https://www.facebook.com/abhi.haththakage/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; or &lt;a href="https://twitter.com/abhixsh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article, and see you soon in the next one! ❤️&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>npm</category>
      <category>programming</category>
    </item>
    <item>
      <title>Motivational Quote Generator: An App to Help You Stay Inspired</title>
      <dc:creator>Abishek Haththakage</dc:creator>
      <pubDate>Sun, 14 May 2023 11:34:56 +0000</pubDate>
      <link>https://forem.com/abhixsh/motivational-quote-generator-an-app-to-help-you-stay-inspired-5h2h</link>
      <guid>https://forem.com/abhixsh/motivational-quote-generator-an-app-to-help-you-stay-inspired-5h2h</guid>
      <description>&lt;p&gt;Success depends heavily on motivation, yet maintaining that motivation is not always simple. We occasionally require that extra push to keep moving forward. The Motivational Quote Generator can help with that. This software was developed to offer users daily doses of motivational inspiration.&lt;/p&gt;

&lt;p&gt;JavaScript, HTML, and CSS were used to create the app. It has a straightforward user interface and shows an inspirational saying and an emoticon to assist establish the mood for the day. By selecting the "Generate Quote" button, users can create a fresh quote. From a list of 34 quotes, the software chooses one at random and displays it on the screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;A API called Motivational Quote Generator offers users a selection of inspirational quotes at random. Users can obtain a fresh quote to inspire and motivate them with just one click on the "Generate Quote" button. The quote is shown on the page by the app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category Submission:
&lt;/h3&gt;

&lt;p&gt;The app has been categorized as &lt;strong&gt;"Wacky Wildcards"&lt;/strong&gt; in the submission.&lt;/p&gt;

&lt;h3&gt;
  
  
  App Link
&lt;/h3&gt;

&lt;p&gt;The app is hosted via github pages. &lt;a href="https://abhixsh.github.io/motivate-me/random-tips.html" rel="noopener noreferrer"&gt;LINK&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&gt;

&lt;p&gt;
&lt;a href="https://ibb.co/qDy8KGp" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FD1VFhXQ%2FScreenshot-158.png" alt="Screenshot-158" width="640" height="360"&gt;&lt;/a&gt;&lt;br&gt;&lt;a href="https://emoticoncentral.com/category/growing-heart" rel="noopener noreferrer"&gt;&lt;/a&gt;
&lt;a href="https://ibb.co/FVrKrDW" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2Frsjmjwt%2FScreenshot-159.png" alt="Screenshot-159" width="640" height="360"&gt;&lt;/a&gt;&lt;br&gt;&lt;a href="https://emoticoncentral.com/category/growing-heart" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;br&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%2Ffudacoamlrnejfdfn35q.gif" 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%2Ffudacoamlrnejfdfn35q.gif" alt="Image description" width="8" height="4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;

&lt;p&gt;JavaScript, CSS, and simple HTML were used to create this project. The list of quotes that are displayed on the website is contained in the quotes array in the JavaScript file. A random quotation is chosen from the quotes array and displayed on the webpage when the user clicks the "Generate Quote" button.&lt;/p&gt;

&lt;p&gt;The webpage's basic structure is contained in the HTML file. The inspirational quotation and emoji are shown in the div element with the id "quote-container". The "generate-btn" id, which is used to pick the button element in JavaScript, is associated with the "Generate Quote" button.&lt;/p&gt;

&lt;p&gt;The website's styles are contained in the CSS file. The background color of the body element is #1c1c1e, and its sans-serif font is from the "Helvetica Neue" family. The maximum width and margin of the webpage are set using the container class. The text-align property of the h1 element is set to center, and the font size is 2.5 rem.&lt;/p&gt;

&lt;p&gt;The deployment of a website to GitHub Pages is automated by the YAML code in this GitHub Actions workflow. This is my sample.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
name: Deploy to GitHub Pages

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build and Deploy
        uses: JamesIves/github-pages-deploy-action@4.1.0
        with:
          branch: gh-pages
          folder: .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Link to Source Code
&lt;/h3&gt;

&lt;p&gt;The app's source code is accessible on GitHub:&lt;a href="https://github.com/abhixsh/motivate-me" rel="noopener noreferrer"&gt;https://github.com/abhixsh/motivate-me&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Permissive License
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://github.com/abhixsh/motivate-me/blob/master/License.md" rel="noopener noreferrer"&gt;MIT license&lt;/a&gt;, a liberal free software license, governs the use of the application. This indicates that there are no restrictions on how the software may be used, updated, or distributed, including for commercial reasons.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background (What made you decide to build this particular app? What inspired you?)
&lt;/h2&gt;

&lt;p&gt;The "Generate Quote" button on this app's APK generates a random inspirational quote each time it is pressed. The website employs HTML, CSS, and JavaScript to produce a simple, aesthetically pleasing, and user-friendly experience. The goal of creating this app was to give users a quick and simple way to receive inspiration and support whenever they need it. The motivational quotes included in the app come from a wide spectrum of well-known people, including politicians, authors, scientists, and artists. They address a variety of issues relating to achievement, perseverance, and personal development. Anyone who needs a little incentive to get through the day can use the app because it is made to be user-friendly for a broad audience.&lt;/p&gt;

&lt;h3&gt;
  
  
  How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?)
&lt;/h3&gt;

&lt;p&gt;This project is set up for CI/CD using GitHub Actions. The GitHub Actions procedure gets activated whenever there is a fresh push to the main branch. The procedure tests the JavaScript file to ensure that it is functioning properly. The workflow launches the project to GitHub Pages if the testing is successful. By doing this, the project is always current and functioning properly. Here I learned about GitHub actions very well to do this project. It added something new to my skill set.&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Resources/Info
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/features/actions" rel="noopener noreferrer"&gt;Features: GitHub Actions&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.github.com/en/actions" rel="noopener noreferrer"&gt;GitHub Actions Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://pages.github.com/" rel="noopener noreferrer"&gt;GitHub Pages&lt;/a&gt;&lt;/p&gt;

</description>
      <category>githubhack23</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>css</category>
    </item>
  </channel>
</rss>
