[Verse 1] Infrastructure as code, that's where we begin No more clicking through consoles, let the typing win HashiCorp's creation, declarative and clean Tell it what you want, not the steps in between Providers connect you to clouds up above AWS, Azure, Google with computational love [Chorus] Plan then apply, that's the Terraform way Plan then apply, see changes display HCL syntax, human-readable blocks Resource and data, like digital building blocks Plan then apply, plan then apply Watch your infrastructure come alive [Verse 2] Configuration files with dot-tf extension Resource blocks declare your infrastructure intention Provider first, then resources follow through Virtual machines, networks, storage too Variables make your templates reusable gold Outputs show the values that stories have told [Chorus] Plan then apply, that's the Terraform way Plan then apply, see changes display HCL syntax, human-readable blocks Resource and data, like digital building blocks Plan then apply, plan then apply Watch your infrastructure come alive [Bridge] State file tracks what's real versus planned Terraform init downloads what you've commanded Plan shows the diff, what will change today Apply makes it happen, infrastructure at play Destroy tears it down when projects are through Immutable systems, always fresh and new [Verse 3] Main dot tf holds your primary design Variables dot tf keeps parameters in line Terraform dot tfvars feeds the hungry machine Outputs dot tf shows what should be seen Version control tracks every single change Collaboration makes infrastructure less strange [Final Chorus] Plan then apply, that's the Terraform way Plan then apply, see changes display HCL syntax, human-readable blocks Resource and data, like digital building blocks Plan then apply, plan then apply Infrastructure as code will never die [Outro] From zero to hero, your first config's done Terraform mastery has only begun
# The Case of the Vanishing Infrastructure ## 1. THE MYSTERY Sarah Chen stared at her laptop screen in disbelief, her coffee growing cold as she refreshed the AWS console for the tenth time in five minutes. The entire development environment for DataFlow Solutions had simply vanished overnight. Twelve virtual machines, three databases, load balancers, and networking components that had taken weeks to configure through the web interface—all gone without a trace. "This is impossible," she muttered, scrolling through the empty resource list. The audit logs showed no human activity, no deletions, nothing. Her colleague Mike rushed over from his desk, drawn by her frustrated sighs. "The client demo is in three hours, and everything we built for the new e-commerce platform has disappeared. We have backups of the code, but recreating all this infrastructure manually..." She gestured helplessly at the blank dashboard. "We're talking days of work, maybe weeks to get everything configured exactly right again." Mike peered over her shoulder, his face pale. "How is that even possible? You can't accidentally delete twelve VMs. There should be confirmation dialogs, warnings..." But the evidence was undeniable. Months of careful point-and-click configuration had evaporated like morning mist. ## 2. THE EXPERT ARRIVES "Sounds like you've run into the classic 'snowflake server' problem," came a calm voice from behind them. They turned to see Alex Rodriguez, the company's newly hired infrastructure consultant, approaching with a knowing smile. Alex had spent the last decade helping companies modernize their technology operations and had seen this exact scenario play out countless times. Alex pulled up a chair, studying the empty console with the detached interest of a detective examining a crime scene. "Let me guess—everything was built manually through the web interface? Lots of clicking, configuring, tweaking until it worked perfectly?" Sarah nodded grimly. "Then someone—or something—came along and swept it all away, leaving you with no way to recreate exactly what you had." ## 3. THE CONNECTION "This," Alex said, tapping the screen, "is why smart infrastructure teams treat their servers and cloud resources like cattle, not pets." Sarah looked confused, so Alex continued with a grin. "When you build infrastructure manually, each server becomes a unique snowflake—precious, irreplaceable, and impossible to recreate exactly. But what if I told you there's a way to treat infrastructure like code? To write down exactly what you want and have it built automatically, perfectly, every time?" Alex opened a text editor and started typing. "This is called Infrastructure as Code, and there's a tool called Terraform that makes it incredibly powerful. Instead of clicking through web interfaces, you write a simple text file that describes what you want—like a recipe for your infrastructure." The concept was starting to click for Mike, who leaned forward with interest. "So if something disappears, you just... run the recipe again?" "Exactly!" Alex's enthusiasm was infectious. "And here's the beautiful part—the same recipe works every time. No forgotten configuration settings, no 'oh, I remember we had to tweak that security group rule' moments. It's all written down in code." ## 4. THE EXPLANATION Alex created a new file called `main.tf` and began explaining as they typed. "Terraform configurations are like writing a letter to your cloud provider. First, you need to tell it who you're talking to." They added a provider block: ``` provider "aws" { region = "us-west-2" } ``` "This is like addressing an envelope—we're telling Terraform we want to talk to AWS, specifically in the US West region," Alex explained. "Think of providers as different stores you might shop at. AWS, Google Cloud, Azure—Terraform can talk to all of them using the same basic language." Sarah was taking notes furiously. "But how does it know what to build?" "Great question! That's where resource blocks come in." Alex continued typing, adding a virtual machine definition. "Each resource block is like ordering an item from a catalog. You specify exactly what you want—the size, the operating system, the name—and Terraform figures out how to create it." They explained how resource blocks worked like LEGO instructions, with each piece clearly defined and named. "Now here's where the magic really happens," Alex said, opening a terminal. "Terraform works in three steps, like a careful contractor. First, you run `terraform init` to set up your workspace—this downloads all the tools Terraform needs to talk to your chosen cloud provider. Then `terraform plan` shows you exactly what Terraform wants to build, like a detailed blueprint. Finally, `terraform apply` actually creates everything." Mike was fascinated by the plan output Alex showed them. "It's like having a crystal ball! You can see exactly what will happen before it happens." Alex nodded enthusiastically. "No surprises, no accidental deletions. And here's the best part—Terraform keeps a state file that tracks everything it built. It's like a detailed inventory list, so it always knows what exists and what needs to change." ## 5. THE SOLUTION "Alright," Alex said, cracking their knuckles, "let's rebuild your infrastructure properly this time." Working together, they recreated the development environment as code, with Sarah describing each component and Alex translating it into Terraform configuration. The EC2 instances, RDS databases, load balancers—everything went into the `main.tf` file as clearly defined resource blocks. "This feels almost too easy," Sarah admitted as they ran `terraform plan`. The output showed exactly the twelve virtual machines, three databases, and networking components they needed. "It's like having a photographic memory of our entire infrastructure." Within minutes of running `terraform apply`, resources began appearing in the AWS console, configured exactly as specified. Mike watched in amazement as the infrastructure materialized. "So if this disappears again..." "We just run `terraform apply` again," Alex finished. "Same result, every time. But more importantly, now we know exactly what we have, and we can version control it, back it up, and share it with the team. No more tribal knowledge or 'it works on my machine' problems." ## 6. THE RESOLUTION Two hours before the client demo, their development environment was not only restored but better than before. Sarah smiled as she reviewed the clean, documented infrastructure code. "I can't believe we were doing this manually for so long. It's like we were building houses with our bare hands when we could have been using blueprints and power tools." "Infrastructure as Code isn't just about automation," Alex concluded, watching the team's relieved faces. "It's about making your infrastructure predictable, repeatable, and recoverable. Plan, Apply, Deploy—three simple steps that turn chaos into clarity." The mystery of the vanishing infrastructure had led them to discover something far more valuable than what they'd lost: the power to treat their infrastructure like the code it should always have been.
← What is Infrastructure as Code? | Terraform State Management →