<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sreya Sharma</title>
    <description>The latest articles on DEV Community by Sreya Sharma (@sreya_sharma_711168ec58fc).</description>
    <link>https://dev.to/sreya_sharma_711168ec58fc</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%2F3645511%2F3c31b7e3-0a0c-41b4-a9c6-d383f97d915e.png</url>
      <title>DEV Community: Sreya Sharma</title>
      <link>https://dev.to/sreya_sharma_711168ec58fc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sreya_sharma_711168ec58fc"/>
    <language>en</language>
    <item>
      <title>Diving into Terraform Provisioners</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Tue, 23 Dec 2025 16:12:24 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/diving-into-terraform-provisioners-5gc1</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/diving-into-terraform-provisioners-5gc1</guid>
      <description>&lt;p&gt;Day 15 was exciting because I learned about Terraform provisioners — a feature that lets you run scripts or commands on your resources during creation or destruction. This added a new dimension to Terraform: it’s not just about creating infrastructure, it can also configure it automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Provisioners?
&lt;/h2&gt;

&lt;p&gt;Provisioners allow Terraform to perform actions on a resource after it’s created or before it’s destroyed.&lt;br&gt;
Think of them as automation hooks for your infrastructure.&lt;/p&gt;

&lt;p&gt;There are two main types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;remote-exec – runs commands on remote machines (like EC2 instances)&lt;/li&gt;
&lt;li&gt;local-exec – runs commands on your local machine&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Provisioners Are Useful
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Installing software or packages on a server after creation&lt;/li&gt;
&lt;li&gt;Running initialization scripts&lt;/li&gt;
&lt;li&gt;Copying files to resources&lt;/li&gt;
&lt;li&gt;Automating post-deployment configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Provisioners help bridge the gap between Terraform and configuration management tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using local-exec
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This runs a command on your local machine instead of the resource.&lt;/li&gt;
&lt;li&gt;Useful for notifications, scripts, or automation outside the cloud provider.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  remote-exec
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This installs Nginx immediately after the EC2 instance is created.&lt;/li&gt;
&lt;li&gt;The connection block tells Terraform how to access the remote machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  File Provisioners
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Uploading a configuration or script to a server&lt;/li&gt;
&lt;li&gt;Copying sensitive files like certificates securely&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Provisioners are optional; Terraform recommends using them sparingly.&lt;/li&gt;
&lt;li&gt;They are useful for bootstrapping and post-creation configuration.&lt;/li&gt;
&lt;li&gt;remote-exec for remote machines, local-exec for local commands.&lt;/li&gt;
&lt;li&gt;Overusing provisioners can lead to imperative code, which goes against Terraform’s declarative nature.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>automation</category>
      <category>devops</category>
      <category>terraform</category>
    </item>
    <item>
      <title>Day 14: My First Mini-Project – Hosting a Static Website on AWS with Terraform</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Thu, 18 Dec 2025 16:18:24 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-14-my-first-mini-project-hosting-a-static-website-on-aws-with-terraform-18hg</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-14-my-first-mini-project-hosting-a-static-website-on-aws-with-terraform-18hg</guid>
      <description>&lt;p&gt;Day 14 was exciting because I applied everything I’ve learned so far in my first mini-project: hosting a static website using AWS S3 and CloudFront, all managed with Terraform. It was hands-on, practical, and a big confidence booster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;The goal was to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Host a static website in an S3 bucket&lt;/li&gt;
&lt;li&gt;Make it securely accessible via CloudFront&lt;/li&gt;
&lt;li&gt;Manage everything through Terraform&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Along the way, I learned how to handle public access, bucket policies, and CloudFront origin access control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Steps I Followed
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create an S3 Bucket
I started with a simple S3 bucket to host the website:&lt;/li&gt;
&lt;li&gt;I kept the bucket private and enabled website hosting.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This ensures content is served only through CloudFront for security.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure Public Access &amp;amp; Bucket Policy&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To allow CloudFront to access the bucket without making it public:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using Origin Access Identity (OAI) ensures S3 content is private and only accessible via CloudFront&lt;/li&gt;
&lt;li&gt;Set Up CloudFront Distribution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudFront handles content delivery and caching for the website:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CloudFront caches content globally and serves it over HTTPS.&lt;/li&gt;
&lt;li&gt;The OAI ensures only CloudFront can access the S3 bucket.&lt;/li&gt;
&lt;li&gt;Upload Website Files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I used Terraform’s aws_s3_bucket_object to upload HTML, CSS, and images:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terraform can manage the content itself, not just infrastructure.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Learnings
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;S3 Bucket &amp;amp; Public Access: Keep buckets private and serve content via CloudFront.&lt;/li&gt;
&lt;li&gt;CloudFront Origin Access Control: Protects your content while allowing secure delivery.&lt;/li&gt;
&lt;li&gt;Bucket Policies: Essential for controlling who can access objects.&lt;/li&gt;
&lt;li&gt;Terraform Automation: I realized how Terraform can manage both infrastructure and content together.&lt;/li&gt;
&lt;li&gt;Real-World Flow: From bucket creation → policy → CloudFront → upload → serve.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Completing this mini-project made Terraform feel very real and practical. It was amazing to see a website live just from my configuration files.&lt;/p&gt;

&lt;p&gt;This project also gave me confidence to tackle more complex setups like multi-region hosting, SSL certificates, or CI/CD integration with Terraform.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>devops</category>
      <category>aws</category>
      <category>terraform</category>
    </item>
    <item>
      <title>Day 13: Understanding Data Sources in Terraform (AWS)</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Wed, 17 Dec 2025 16:32:38 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-13-understanding-data-sources-in-terraform-aws-k0g</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-13-understanding-data-sources-in-terraform-aws-k0g</guid>
      <description>&lt;p&gt;Day 13 was an important milestone in my Terraform learning journey. Until now, most of my work was about creating and managing resources. Today, I learned something equally powerful — data sources.&lt;/p&gt;

&lt;p&gt;Data sources allow Terraform to read existing infrastructure instead of creating new resources. This concept made Terraform feel more practical and closer to real-world use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Data Sources in Terraform?
&lt;/h2&gt;

&lt;p&gt;A data source is used when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A resource already exists in AWS&lt;/li&gt;
&lt;li&gt;You want to reference it in Terraform&lt;/li&gt;
&lt;li&gt;You don’t want Terraform to create or modify it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In simple words, resources create, but data sources read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Data Sources Are Important
&lt;/h2&gt;

&lt;p&gt;In real projects, not everything is created by Terraform. Sometimes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VPCs already exist&lt;/li&gt;
&lt;li&gt;AMIs are prebuilt&lt;/li&gt;
&lt;li&gt;IAM roles are managed by another team&lt;/li&gt;
&lt;li&gt;S3 buckets already exist
Data sources help Terraform fetch this information and use it safely.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic Syntax of a Data Source
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data "&amp;lt;provider&amp;gt;_&amp;lt;resource_type&amp;gt;" "&amp;lt;name&amp;gt;" {
  # filters or identifiers
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common AWS Data Sources I Explored&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VPC&lt;/li&gt;
&lt;li&gt;Subnet&lt;/li&gt;
&lt;li&gt;AMI&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Resource vs Data Source (Simple Understanding)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Resources create and manage&lt;/li&gt;
&lt;li&gt;Data sources read and reference&lt;/li&gt;
&lt;li&gt;Resources change infrastructure&lt;/li&gt;
&lt;li&gt;Data sources do not make changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding this difference cleared up a lot of confusion for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Took Away from Day 13
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Data sources make Terraform more dynamic&lt;/li&gt;
&lt;li&gt;Existing infrastructure can be reused safely&lt;/li&gt;
&lt;li&gt;Hardcoding values should be avoided&lt;/li&gt;
&lt;li&gt;Most real-world Terraform projects rely heavily on data sources&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>learning</category>
      <category>terraform</category>
    </item>
    <item>
      <title>Day 12: Going Deeper into Terraform Functions and Validations</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Tue, 16 Dec 2025 16:22:18 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-12-going-deeper-into-terraform-functions-and-validations-1j34</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-12-going-deeper-into-terraform-functions-and-validations-1j34</guid>
      <description>&lt;p&gt;Day 12 was about understanding how Terraform handles time, data types, files, numbers, and validations. These topics may look small individually, but together they play a huge role in writing safe, flexible, and production-ready Terraform code.&lt;/p&gt;

&lt;p&gt;This day helped me realize that Terraform is not just about creating resources — it’s also about controlling data and preventing mistakes before they happen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with Date and Time Functions
&lt;/h2&gt;

&lt;p&gt;Terraform provides functions to work with time-based values, which are useful for tagging, tracking, and automation.&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;locals {
  created_time = timestamp()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Input Validation: Preventing Wrong Values
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Validation blocks ensure that incorrect input values are rejected before Terraform runs.&lt;/li&gt;
&lt;li&gt;This avoids mistakes like passing invalid environment names and helps keep infrastructure consistent.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Numeric Functions in Terraform
&lt;/h2&gt;

&lt;p&gt;Numeric functions help perform calculations inside Terraform.&lt;/p&gt;

&lt;p&gt;Examples&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;max(3, 5, 7)
min(1, 2, 3)
abs(-10)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are useful when dealing with scaling values, limits, or thresholds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading Files Using the file Function
&lt;/h2&gt;

&lt;p&gt;The file function allows Terraform to read content from a file and use it inside the configuration.&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;locals {
  policy = file("policy.json")
}

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

&lt;/div&gt;



&lt;p&gt;This is very useful when attaching IAM policies, user data scripts, or configuration templates without hardcoding them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned from Day 12
&lt;/h2&gt;

&lt;p&gt;After practicing these concepts, a few things became clear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terraform can handle dynamic values easily&lt;/li&gt;
&lt;li&gt;Validations catch errors early&lt;/li&gt;
&lt;li&gt;File handling keeps code clean&lt;/li&gt;
&lt;li&gt;Type conversions prevent runtime failures&lt;/li&gt;
&lt;li&gt;Numeric functions support smarter scaling logic&lt;/li&gt;
&lt;li&gt;These features add reliability to Terraform projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Takeaways from Day 12
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Date and time functions help with tracking&lt;/li&gt;
&lt;li&gt;Type conversion avoids data mismatch issues&lt;/li&gt;
&lt;li&gt;File function prevents hardcoding&lt;/li&gt;
&lt;li&gt;Validation blocks improve safety&lt;/li&gt;
&lt;li&gt;Numeric functions support logical decisions&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Day 11: Understanding Terraform Functions Through Real Use Cases</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Mon, 15 Dec 2025 14:20:30 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-11-understanding-terraform-functions-through-real-use-cases-397a</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-11-understanding-terraform-functions-through-real-use-cases-397a</guid>
      <description>&lt;p&gt;Day 11 was all about Terraform functions — and honestly, this was the day when my code started to feel cleaner and more controlled. Instead of manually fixing values or writing extra logic, I learned how built-in functions can handle common problems in a simple and readable way.&lt;/p&gt;

&lt;p&gt;Functions in Terraform help transform, format, and manage data without complicating the configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Terraform Functions Matter
&lt;/h2&gt;

&lt;p&gt;In real projects, inputs are not always perfect. Names come in different formats, values need to be combined, and maps need safe lookups. Functions solve these problems inside Terraform itself.&lt;/p&gt;

&lt;p&gt;Today, I explored some commonly used and very practical functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;lower&lt;/li&gt;
&lt;li&gt;upper&lt;/li&gt;
&lt;li&gt;merge&lt;/li&gt;
&lt;li&gt;split&lt;/li&gt;
&lt;li&gt;lookup&lt;/li&gt;
&lt;li&gt;&lt;p&gt;replace&lt;br&gt;
&lt;strong&gt;Working with Text: lower and upper&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These functions are mainly used to keep naming consistent, especially for resource names and tags.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is useful when AWS resources require lowercase names or when you want standardized tags.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Combining Maps with merge&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The merge function is helpful when you want to combine multiple maps, especially for tags.&lt;/li&gt;
&lt;li&gt;This avoids repeating the same tags across resources and keeps tagging clean and centralized.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Breaking Strings Using split&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;split is used when you want to convert a string into a list.&lt;/li&gt;
&lt;li&gt;This is helpful when inputs come as comma-separated values and need to be processed further.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Safe Map Access with lookup&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The lookup function prevents errors when accessing map values.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the key doesn’t exist, Terraform uses the default value instead of failing.&lt;br&gt;
**&lt;br&gt;
Modifying Strings Using replace**&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The replace function is used to modify part of a string.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is helpful when switching environments or reusing naming patterns without rewriting everything.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I Learned from Today’s Practice
&lt;/h2&gt;

&lt;p&gt;After working with these functions, I realized:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Functions reduce manual errors &lt;/li&gt;
&lt;li&gt;Code becomes more readable and reusable&lt;/li&gt;
&lt;li&gt;Naming consistency becomes easier&lt;/li&gt;
&lt;li&gt;Terraform feels more like programming logic, not just configuration&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These small tools make a big difference in real-world infrastructure code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways from Day 11
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Functions transform and control input values&lt;/li&gt;
&lt;li&gt;lower and upper standardize text&lt;/li&gt;
&lt;li&gt;merge simplifies tag management&lt;/li&gt;
&lt;li&gt;split helps process string inputs&lt;/li&gt;
&lt;li&gt;lookup avoids runtime errors&lt;/li&gt;
&lt;li&gt;replace makes refactoring easier&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>tutorial</category>
      <category>terraform</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Day 10: Making Terraform Smarter with Conditions, Dynamic Blocks, and Splat Expressions</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Sun, 14 Dec 2025 07:11:44 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-10-making-terraform-smarter-with-conditions-dynamic-blocks-and-splat-expressions-5c0o</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-10-making-terraform-smarter-with-conditions-dynamic-blocks-and-splat-expressions-5c0o</guid>
      <description>&lt;p&gt;Day 10 was one of those days where Terraform started to feel less like static configuration and more like real logic. Until now, I was mostly writing fixed resources. Today, I learned how to make Terraform react to conditions, generate blocks dynamically, and handle multiple resources cleanly.&lt;/p&gt;

&lt;p&gt;This session focused on three important concepts: conditional expressions, dynamic blocks, and splat expressions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conditional Expressions in Terraform
&lt;/h2&gt;

&lt;p&gt;Conditional expressions help Terraform make decisions based on values. Instead of writing separate resources for different environments, we can control behavior using conditions.&lt;/p&gt;

&lt;p&gt;The basic format looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;condition ? true_value : false_value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dynamic Blocks: Writing Less, Doing More
&lt;/h2&gt;

&lt;p&gt;Dynamic blocks were one of the most interesting parts of today’s learning. They allow Terraform to generate repeated blocks automatically, instead of writing the same configuration multiple times.&lt;/p&gt;

&lt;p&gt;This is especially useful when a resource has nested blocks like ingress rules or tags.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dynamic "ingress" {
  for_each = var.ingress_rules
  content {
    from_port   = ingress.value.from
    to_port     = ingress.value.to
    protocol    = ingress.value.protocol
    cidr_blocks = ingress.value.cidr
  }
}

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

&lt;/div&gt;



&lt;p&gt;What I liked about this is how clean the configuration becomes. Instead of repeating the same block again and again, Terraform handles it in a loop-like way.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic blocks make the code:&lt;/li&gt;
&lt;li&gt;Easier to maintain&lt;/li&gt;
&lt;li&gt;Less repetitive&lt;/li&gt;
&lt;li&gt;More flexible&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Splat Expressions: Working with Multiple Resources
&lt;/h2&gt;

&lt;p&gt;Splat expressions are used when multiple resources are created and we want to access their attributes together.&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws_instance.example[*].id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns a list of all instance IDs created under that resource.&lt;/p&gt;

&lt;p&gt;Splat expressions are very helpful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using count or for_each&lt;/li&gt;
&lt;li&gt;Passing multiple values to outputs&lt;/li&gt;
&lt;li&gt;Avoiding manual indexing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It made my code feel cleaner and easier to understand.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Understood After Practicing
&lt;/h2&gt;

&lt;p&gt;Before today, I was writing Terraform in a very fixed way. After learning these concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Conditional expressions helped reduce duplicate code&lt;/li&gt;
&lt;li&gt;Dynamic blocks simplified repeated configurations&lt;/li&gt;
&lt;li&gt;Splat expressions made handling multiple resources easier&lt;/li&gt;
&lt;li&gt;Terraform felt more logical and flexible&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hands-on practice made these concepts much clearer than just reading about them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways from Day 10
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Terraform supports conditional logic&lt;/li&gt;
&lt;li&gt;Dynamic blocks reduce repetition&lt;/li&gt;
&lt;li&gt;Splat expressions simplify multi-resource outputs&lt;/li&gt;
&lt;li&gt;These features make Terraform more scalable&lt;/li&gt;
&lt;li&gt;Clean logic leads to clean infrastructure code&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Day 09: Learning Terraform Lifecycle Rules</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Thu, 11 Dec 2025 13:27:36 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-09-learning-terraform-lifecycle-rules-3ai7</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-09-learning-terraform-lifecycle-rules-3ai7</guid>
      <description>&lt;p&gt;Day 09 of my Terraform journey was all about resource lifecycle management.&lt;br&gt;
Until today, I thought lifecycle rules were just optional settings people rarely use. But after practicing them hands-on, I realized how important they are when dealing with real infrastructure changes.&lt;/p&gt;

&lt;p&gt;Terraform lifecycles let you control what Terraform should or should not do when something changes. This is extremely useful in production environments where accidental updates or deletions can cause problems.&lt;br&gt;
Why Lifecycle Rules Matter&lt;/p&gt;

&lt;p&gt;In many cases, we don’t want Terraform to automatically:&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Lifecycle Rules Matter
&lt;/h2&gt;

&lt;p&gt;In many cases, we don’t want Terraform to automatically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;delete a resource&lt;/li&gt;
&lt;li&gt;replace a resource&lt;/li&gt;
&lt;li&gt;modify something that is sensitive&lt;/li&gt;
&lt;li&gt;recreate something every time a change happens
Lifecycle rules help us put guardrails around our infrastructure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1.create_before_destroy: Avoid Downtime&lt;/p&gt;

&lt;p&gt;This setting tells Terraform to create the new resource first, and only then destroy the old one.&lt;/p&gt;

&lt;p&gt;2.prevent_destroy: Safety Lock&lt;/p&gt;

&lt;p&gt;This was the most interesting one for me:&lt;br&gt;
It literally blocks Terraform from destroying the resource, even if it is removed from the code.&lt;/p&gt;

&lt;p&gt;3.ignore_changes: Ignore Specific Updates&lt;/p&gt;

&lt;p&gt;Sometimes a resource updates outside Terraform (like in AWS console).&lt;br&gt;
Instead of Terraform trying to “fix it” on every apply, we can tell it to ignore certain changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Understood Practically
&lt;/h2&gt;

&lt;p&gt;When I tried modifying values in my configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terraform wanted to recreate the resource&lt;/li&gt;
&lt;li&gt;Lifecycle rules helped control what should and shouldn’t be changed&lt;/li&gt;
&lt;li&gt;Adding prevent_destroy stopped accidental deletion&lt;/li&gt;
&lt;li&gt;Using ignore_changes prevented unnecessary updates&lt;/li&gt;
&lt;li&gt;create_before_destroy ensured continuous availability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hands-on practice made the purpose of lifecycle rules very clear.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways from Day 09
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Lifecycle rules give us control over Terraform behavior&lt;/li&gt;
&lt;li&gt;They prevent accidental deletions&lt;/li&gt;
&lt;li&gt;They avoid unnecessary recreations&lt;/li&gt;
&lt;li&gt;They keep critical resources safe&lt;/li&gt;
&lt;li&gt;They are heavily used in production Terraform code&lt;/li&gt;
&lt;li&gt;Lifecycle rules improve stability and predictability&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devjournal</category>
      <category>devops</category>
      <category>learning</category>
      <category>terraform</category>
    </item>
    <item>
      <title>Day 08: Understanding Terraform Meta-Arguments</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Wed, 10 Dec 2025 12:59:39 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-08-understanding-terraform-meta-arguments-2e13</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-08-understanding-terraform-meta-arguments-2e13</guid>
      <description>&lt;p&gt;Day 08 was about something I had seen many times in Terraform code but never fully understood — meta-arguments.&lt;/p&gt;

&lt;p&gt;At first, they looked like advanced or optional features. But after practicing them hands-on, I realized that meta-arguments control how Terraform creates resources, not just what it creates.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Meta-Arguments in Terraform?
&lt;/h2&gt;

&lt;p&gt;Meta-arguments are special arguments that work across many Terraform resources.&lt;br&gt;
They are not specific to AWS, EC2, or S3 — instead, they change the behavior and lifecycle of resources.&lt;/p&gt;

&lt;p&gt;Some of the most commonly used meta-arguments are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;depends_on&lt;/li&gt;
&lt;li&gt;count&lt;/li&gt;
&lt;li&gt;for_each&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These play a huge role in real-world Terraform projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Explicit Dependency with depends_on
&lt;/h2&gt;

&lt;p&gt;Terraform usually understands dependencies automatically.&lt;br&gt;
But sometimes, dependencies are not obvious — and that’s where depends_on is useful.&lt;br&gt;
This helps avoid errors where one resource must exist before another can be created.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Multiple Resources with count
&lt;/h2&gt;

&lt;p&gt;The count meta-argument is used when you need multiple identical resources.&lt;br&gt;
Resources are indexed, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;aws_instance.example[0]&lt;/li&gt;
&lt;li&gt;aws_instance.example[1]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;count works best when resources are mostly identical and only the number changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Managing Resources with for_each
&lt;/h2&gt;

&lt;p&gt;for_each is more flexible than count and is very useful when working with maps or sets.&lt;br&gt;
With for_each, each resource gets a unique key, making updates safer and clearer.&lt;/p&gt;

&lt;p&gt;Compared to count, for_each avoids index-based confusion when values change.&lt;/p&gt;

&lt;h2&gt;
  
  
  count vs for_each (What I Noticed)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;count is simple but index-based&lt;/li&gt;
&lt;li&gt;for_each is safer and easier to manage&lt;/li&gt;
&lt;li&gt;for_each works well with maps and sets&lt;/li&gt;
&lt;li&gt;Changing count can cause resource recreation&lt;/li&gt;
&lt;li&gt;for_each keeps resource identity stable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In real projects, for_each feels more reliable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Meta-Arguments Matter
&lt;/h2&gt;

&lt;p&gt;Before learning meta-arguments, Terraform felt limited to single resources.&lt;br&gt;
After understanding them, I could:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Control resource creation order&lt;/li&gt;
&lt;li&gt;Dynamically scale resources&lt;/li&gt;
&lt;li&gt;Write cleaner and reusable code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Meta-arguments make Terraform powerful and production-ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned on Day 08
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Meta-arguments change resource behavior, not infrastructure logic&lt;/li&gt;
&lt;li&gt;depends_on handles explicit dependencies&lt;/li&gt;
&lt;li&gt;count is useful for identical resources&lt;/li&gt;
&lt;li&gt;for_each is better for complex and dynamic setups&lt;/li&gt;
&lt;li&gt;Choosing the right meta-argument avoids future issues.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Day 07: Getting Comfortable with Terraform Variables</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Tue, 09 Dec 2025 17:19:55 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-07-getting-comfortable-with-terraform-variables-4p0p</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-07-getting-comfortable-with-terraform-variables-4p0p</guid>
      <description>&lt;p&gt;Day 07 was all about variables, but this time I didn’t just read about them — I actually worked with them deeply. After today, Terraform code started feeling much cleaner and easier to manage.&lt;/p&gt;

&lt;p&gt;Earlier, my configurations had many hardcoded values. Today’s learning showed me why that’s not a good idea and how variables make Terraform projects more flexible and readable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Variables Matter More Than I Thought
&lt;/h2&gt;

&lt;p&gt;When you’re writing small Terraform examples, hardcoding values feels fine. But as soon as a project grows, it becomes confusing very quickly.&lt;/p&gt;

&lt;p&gt;Using variables helped me:&lt;/p&gt;

&lt;p&gt;A&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;void repeating the same values&lt;/li&gt;
&lt;li&gt;Change configurations easily&lt;/li&gt;
&lt;li&gt;Write cleaner, more meaningful code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Creating a separate variables.tf file made a big difference. Everything related to inputs was in one place, and the main configuration felt much simpler.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Variable Types I Worked With
&lt;/h2&gt;

&lt;p&gt;I started with the basic types and used them in real resources.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;String&lt;/strong&gt;: Used for names and regions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Number&lt;/strong&gt;: Used for counts and sizes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Boolean&lt;/strong&gt;: Helped in enabling or disabling features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;List&lt;/strong&gt;: Used when order matters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set&lt;/strong&gt;: Similar to a list, but without duplicate values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tuple&lt;/strong&gt;: Used when multiple values of different types are grouped together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Map / Dictionary&lt;/strong&gt;: Very useful for tags and key-value data&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Keeping Variables in a Separate File
&lt;/h2&gt;

&lt;p&gt;Instead of spreading variables across files, I created a dedicated variables.tf file. This small change made the whole project easier to understand and maintain.&lt;/p&gt;

&lt;p&gt;Pairing it with terraform.tfvars allowed me to change values without touching the main code, which felt very clean and professional.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Took Away from Day 07
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Variables reduce hardcoding and repetition&lt;/li&gt;
&lt;li&gt;Collection types make configurations flexible&lt;/li&gt;
&lt;li&gt;Maps are perfect for tags and metadata&lt;/li&gt;
&lt;li&gt;Separate variable files keep projects organized&lt;/li&gt;
&lt;li&gt;Terraform code becomes easier to read and modify&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Today’s learning made Terraform feel much more practical. Variables are not just a concept — they actually shape how clean and reusable your infrastructure code becomes.&lt;/p&gt;

&lt;p&gt;Day 07 gave me more confidence to write Terraform projects in a structured and real-world way rather than just experimenting.&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>beginners</category>
      <category>learning</category>
      <category>terraform</category>
    </item>
    <item>
      <title>Day 06: Understanding a Clean Terraform Project Structure</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Mon, 08 Dec 2025 12:49:06 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-06-understanding-a-clean-terraform-project-structure-3hcn</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-06-understanding-a-clean-terraform-project-structure-3hcn</guid>
      <description>&lt;p&gt;On Day 06 of my Terraform learning journey, I focused on something that is easy to ignore early on but becomes extremely important as projects grow: project structure.&lt;/p&gt;

&lt;p&gt;Writing Terraform code is not just about making it work—it’s about making it easy to read, maintain, and scale. A clean project structure helps avoid confusion, reduces mistakes, and makes collaboration much smoother.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Project Structure Matters in Terraform
&lt;/h2&gt;

&lt;p&gt;As Terraform projects grow, putting everything into a single file quickly becomes messy. Separating configuration into logical files improves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Readability&lt;/li&gt;
&lt;li&gt;Debugging&lt;/li&gt;
&lt;li&gt;Collaboration&lt;/li&gt;
&lt;li&gt;Long-term maintainability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Terraform automatically loads all .tf files in a directory, so splitting files does not affect execution.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A common and clean Terraform project structure looks like this:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;`&lt;/p&gt;

&lt;p&gt;terraform-project/&lt;br&gt;
│&lt;br&gt;
├── main.tf&lt;br&gt;
├── provider.tf&lt;br&gt;
├── backend.tf&lt;br&gt;
├── variables.tf&lt;br&gt;
├── outputs.tf&lt;br&gt;
├── terraform.tfvars&lt;br&gt;
├── .gitignore&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;Each file has a clear responsibility.&lt;/p&gt;
&lt;h2&gt;
  
  
  Purpose of Each File
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;main.tf: Contains the core resource definitions such as EC2, S3, VPC, etc.&lt;/li&gt;
&lt;li&gt;provider.tf: Defines the provider configuration.&lt;/li&gt;
&lt;li&gt;backend.tf: Used to configure remote state storage.&lt;/li&gt;
&lt;li&gt;variables.tf: Declares all input variables.&lt;/li&gt;
&lt;li&gt;terraform.tfvars: Stores actual variable values.&lt;/li&gt;
&lt;li&gt;outputs.tf: Defines output values after apply.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Using .gitignore in Terraform Projects
&lt;/h2&gt;

&lt;p&gt;Some Terraform files should never be pushed to GitHub because they contain sensitive or generated data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
.terraform/
*.tfstate
*.tfstate.backup
terraform.tfvars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why This Matters?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;State files may contain secrets&lt;/li&gt;
&lt;li&gt;Provider binaries are auto-generated&lt;/li&gt;
&lt;li&gt;Variable files may store sensitive values
Ignoring these files protects your infrastructure and credentials.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Key Learnings from Day 06&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terraform automatically reads all .tf files in a directory&lt;/li&gt;
&lt;li&gt;Splitting configuration improves clarity&lt;/li&gt;
&lt;li&gt;Clean structure prevents mistakes in large projects&lt;/li&gt;
&lt;li&gt;Git ignore rules protect sensitive data&lt;/li&gt;
&lt;li&gt;Good structure reflects professional Terraform practices&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A good Terraform project is not just about resources—it’s about organization. Structuring files properly makes Terraform code easier to understand, safer to manage, and ready for real-world use.&lt;/p&gt;

&lt;p&gt;Day 06 reinforced that clean Infrastructure as Code starts with a clean structure.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Day 05: Understanding Variables in Terraform</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Sun, 07 Dec 2025 12:42:10 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-05-understanding-variables-in-terraform-5gpj</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-05-understanding-variables-in-terraform-5gpj</guid>
      <description>&lt;p&gt;On Day 05 of my Terraform learning journey, I focused on one of the most important building blocks of reusable and flexible Infrastructure as Code: Terraform variables.&lt;/p&gt;

&lt;p&gt;Variables help remove hardcoded values, improve readability, and make Terraform configurations easier to manage across environments.&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  Types of Variables in Terraform
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Terraform primarily works with three kinds of variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input variables&lt;/li&gt;
&lt;li&gt;Local variables&lt;/li&gt;
&lt;li&gt;Output variables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each serves a specific purpose in Terraform configurations.&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  Input Variables
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Input variables allow users to provide values dynamically instead of hardcoding them.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;variable "bucket_name" {
  type    = string
  default = "my-demo-bucket"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Used in a resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
resource "aws_s3_bucket" "example" {
  bucket = var.bucket_name
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Input variables make configurations reusable and environment-independent.&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  Local Variables
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Local variables are used to calculate or store values internally within a configuration.&lt;br&gt;
They reduce repetition and improve readability.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;locals {
  environment = "dev"
  bucket_tag  = "${local.environment}-s3-bucket"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tags = {
  Name = local.bucket_tag
}

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

&lt;/div&gt;



&lt;p&gt;Locals cannot be overridden from the command line.&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  Output Variables
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Output variables display values after Terraform applies the configuration.&lt;br&gt;
They are useful for debugging and for passing information to other modules.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;output "bucket_name" {
  value = aws_s3_bucket.example.bucket
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After terraform apply, the bucket name is printed in the terminal.&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  Terraform Variable Data Types
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Terraform supports multiple data types, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;string – text values&lt;/li&gt;
&lt;li&gt;number – integers and decimals&lt;/li&gt;
&lt;li&gt;bool – true or false&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;variable "region" {
  type    = string
  default = "ap-south-1"
}

variable "instance_count" {
  type    = number
  default = 1
}

variable "enable_versioning" {
  type    = bool
  default = true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Default Values and Null
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Default Values&lt;/p&gt;

&lt;p&gt;A default value allows Terraform to use a variable automatically if no value is provided.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
variable "environment" {
  type    = string
  default = "dev"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Null Values
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;The null value means no value is set.&lt;br&gt;
Terraform ignores arguments set to null, which helps in conditional configurations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;variable "bucket_acl" {
  type    = string
  default = null
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If bucket_acl is null, Terraform simply does not apply it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Takeaways from Day 05&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Variables make Terraform flexible and reusable&lt;/li&gt;
&lt;li&gt;Input variables accept user-provided values&lt;/li&gt;
&lt;li&gt;Local variables simplify internal expressions&lt;/li&gt;
&lt;li&gt;Output variables expose useful information. &lt;/li&gt;
&lt;li&gt;Data types improve validation and safety&lt;/li&gt;
&lt;li&gt;Default and null help with optional configurations.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Understanding variables is critical to writing clean and scalable Terraform code. By using input, local, and output variables correctly, Terraform configurations become more readable, reusable, and easier to maintain across different environments.&lt;/p&gt;

&lt;p&gt;Day 05 strengthened the foundation needed to move toward more advanced Terraform concepts.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Day 04: Terraform State File — The Backbone of Infrastructure as Code</title>
      <dc:creator>Sreya Sharma</dc:creator>
      <pubDate>Sat, 06 Dec 2025 08:23:15 +0000</pubDate>
      <link>https://dev.to/sreya_sharma_711168ec58fc/day-04-terraform-state-file-the-backbone-of-infrastructure-as-code-30bd</link>
      <guid>https://dev.to/sreya_sharma_711168ec58fc/day-04-terraform-state-file-the-backbone-of-infrastructure-as-code-30bd</guid>
      <description>&lt;p&gt;On Day 04 of my Terraform learning journey, I covered one of the most critical and often underestimated components of Terraform: the state file.&lt;/p&gt;

&lt;p&gt;Until this point, Terraform felt simple—write code, plan, apply. However, understanding how Terraform tracks infrastructure, detects changes, and protects sensitive data requires a deep understanding of the Terraform state and its management.&lt;/p&gt;

&lt;p&gt;This day focused on what state files are, why they matter, how remote backends improve security, and how to manage state safely using Terraform commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Terraform State File?
&lt;/h2&gt;

&lt;p&gt;Terraform stores information about managed infrastructure in a file called terraform.tfstate.&lt;/p&gt;

&lt;p&gt;The state file acts as a source of truth for Terraform by tracking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What resources exist&lt;/li&gt;
&lt;li&gt;Their current attributes&lt;/li&gt;
&lt;li&gt;How Terraform maps configuration to real-world infrastructure
Terraform uses this state file to determine what already exists and what needs to change.
**&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Desired State vs Actual State
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Terraform operates by comparing two states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Desired State
Defined in Terraform configuration files (.tf)
-Actual State
Pulled from real infrastructure providers like AWS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The state file stores the last known actual state.&lt;br&gt;
During terraform plan, Terraform compares:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Desired State (code)
        vs
Terraform State
        vs
Actual Infrastructure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Terraform State Is Sensitive
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;The state file often contains sensitive data, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Resource IDs&lt;/li&gt;
&lt;li&gt;IP addresses&lt;/li&gt;
&lt;li&gt;Database endpoints&lt;/li&gt;
&lt;li&gt;IAM role ARNs&lt;/li&gt;
&lt;li&gt;Sometimes plaintext secrets and passwords&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Storing terraform.tfstate locally or pushing it to GitHub can lead to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Credential leakage&lt;/li&gt;
&lt;li&gt;Infrastructure misuse&lt;/li&gt;
&lt;li&gt;Security breaches&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because of this, state files should never be committed to version control.&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Use a Remote Backend?
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;A remote backend stores the state file in a centralized, secure location instead of local storage.&lt;/p&gt;

&lt;p&gt;Using a remote backend helps to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prevent accidental state exposure&lt;/li&gt;
&lt;li&gt;Enable team collaboration&lt;/li&gt;
&lt;li&gt;Avoid state conflicts&lt;/li&gt;
&lt;li&gt;Ensure consistency across environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For AWS-based workflows, S3 is commonly used as a remote backend.&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting Up Remote Backend Using S3
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Example Backend Configuration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform {
  backend "s3" {
    bucket         = "my-terraform-state-bucket"
    key            = "dev/terraform.tfstate"
    region         = "ap-south-1"
    encrypt        = true
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for Terraform State Management
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never commit .tfstate files to Git&lt;/li&gt;
&lt;li&gt;Always use a remote backend for teams and production&lt;/li&gt;
&lt;li&gt;Enable encryption for state storage&lt;/li&gt;
&lt;li&gt;Use state locking to prevent concurrent changes&lt;/li&gt;
&lt;li&gt;Restrict access to the state bucket using IAM policies&lt;/li&gt;
&lt;li&gt;Maintain separate state files for different environments
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*.tfstate
*.tfstate.backup
.terraform/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Terraform State Management Commands
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Terraform provides powerful commands to inspect and manipulate state safely.&lt;/p&gt;

&lt;p&gt;List Resources in State&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Displays all resources currently tracked by Terraform.&lt;/p&gt;

&lt;p&gt;Show a Specific Resource&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`terraform state show aws_s3_bucket.example`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shows full details of a resource as stored in the state file.&lt;/p&gt;

&lt;p&gt;Remove a Resource from State&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform state rm aws_s3_bucket.example
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removes a resource from state without destroying it in AWS.&lt;/p&gt;

&lt;p&gt;Useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Resources were deleted manually&lt;/li&gt;
&lt;li&gt;You want Terraform to stop managing a resource&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Move a Resource in State&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform state mv aws_instance.old aws_instance.new
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moves a resource from one address to another without recreation.&lt;br&gt;
**&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Terraform State Is the Heart of IaC
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Terraform code defines what you want.&lt;br&gt;
Terraform state defines what exists.&lt;/p&gt;

&lt;p&gt;Without the state file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terraform cannot detect changes&lt;/li&gt;
&lt;li&gt;Resources may be duplicated&lt;/li&gt;
&lt;li&gt;Infrastructure consistency is lost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding state management transforms Terraform from a simple automation tool into a production-grade infrastructure management system.&lt;br&gt;
**&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways from Day 04
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terraform state tracks real infrastructure&lt;/li&gt;
&lt;li&gt;State files contain sensitive information&lt;/li&gt;
&lt;li&gt;Remote backends improve security and collaboration&lt;/li&gt;
&lt;li&gt;S3 + DynamoDB enable secure state storage and locking&lt;/li&gt;
&lt;li&gt;Terraform state commands provide powerful control&lt;/li&gt;
&lt;li&gt;Proper state management is non-negotiable for production&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Day 04 highlighted that Terraform is not just about writing .tf files. Proper state handling is what makes Infrastructure as Code reliable, secure, and scalable. Mastering state management ensures that infrastructure changes are controlled, auditable, and safe.&lt;/p&gt;

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