Ravindra BagaleCourses & study guides Track your progress

Guides

Terraform: पहला Plan और Apply

Read this guide in: English · मराठी · हिंदी

Why Terraform चाहिए? क्योंकि cloud resources सिर्फ़ click history हों तो developers और operations में problem आता है। Developers को app के लिए VPC, VM या storage चाहिए। Operations — server / cloud side — हर हफ़्ते console अलग तरह से click करता है। किसने क्या बनाया याद नहीं। Terraform .tf files में resources declare करता है: init → plan → apply → lab खत्म हो तो destroy। Apply से पहले plan पढ़ो।

संक्षिप्त उत्तर

  1. Developer — app के लिए cloud resources चाहिए।
  2. Operations — cloud/server-side person जिसे पता हो क्या है और क्यों।
  3. Problem — click-ops; drift; “किसने बनाया?”; surprise bills।
  4. Terraform — code desired cloud बताता है; plan preview; apply reality बदलता है।
  5. Pocket: init → plan (पढ़ो) → apply → labs destroy.

Language: English · मराठी · हिंदी

Problem? Suppose we are…

Suppose we are building Instagram (like updates)

किसी ने console में bucket और VM click किए। छह महीने बाद production किसने बनाया पता नहीं। Friday को गलत resource delete।

Suppose we are working at Netflix and we are giving updates

बार‑बार releases — हर environment एक जैसा infra shape। Click-ops Netflix-scale identical नहीं रख सकता।

Suppose you are working in Infosys on a client project

Client operations कहता है: “हमारे account में कुछ बनाने से पहले plan दिखाओ।” terraform plan वही बातचीत।

अपने cloud account के credentials, budget alerts। Invented prices नहीं। Secrets / terraform.tfstate बेपरवाह commit न करें।

Terraform plan then apply Terraform reads .tf files, shows a plan of create/change/destroy, then apply makes infrastructure match the code. State tracks what exists. .tf files desired state HCL init providers plan + create ~ change - destroy apply Cloud API State file tracks real resources — read the plan before typing yes code → infrastructure Teaching flow only — not a fake AWS console screenshot

Terraform reads .tf files, shows a plan (+/~/-), then apply makes infrastructure match the code.

Terraform plan and apply Terminal-style teaching diagram of terraform init, plan and apply using a local_file example — not a cloud console.

Terminal-style teaching diagram: terraform init, plan, apply with a local lab example — not a fake AWS console.

Terraform कैसे जवाब देता है

mkdir tflab && cd tflab
terraform version
terraform init
terraform plan
terraform apply
terraform destroy

Minimal .tf — सिर्फ़ अनुमति वाले provider/resource, वर्तमान HashiCorp registry docs:

terraform {
  required_version = ">= 1.5.0"
}
# provider + resource official docs से

Ravindra Bagale's Tip

Init खत्म होते ही apply मत करो। Plan ज़रूरी पढ़ना। Client account पर आँख बंद OK click नहीं। Labs उसी दिन destroy जहाँ हो सके। याद रखो।

Samajla ka? Why Terraform = click-ops mystery रोकें; Instagram / Netflix / Infosys “suppose”; init → plan → apply → destroy। हर plan पढ़ो।

Frequently asked questions

What is Terraform?

An infrastructure-as-code tool: you declare desired cloud resources in files, and Terraform calls provider APIs.

What is state?

Terraform records what it created in a state file so later plans know the real world.

Why plan before apply?

Plan is a dry run. Apply makes real changes — always read the plan.

Is local state OK for learning?

Yes for solo labs. Teams use remote state backends — learn that after the first apply.

Terraform vs Ansible?

Terraform shines at provisioning infrastructure. Ansible shines at configuring software on machines.

How do I avoid surprise bills?

Use tiny resources, set billing alerts in your cloud, and destroy labs when finished.