Terraform sounded promising when I first heard about it, so I did what everyone does: read the docs, overthought it, and procrastinated. Eventually I stopped reading and started using it. That changed everything - Claude, I'm staring at you.
| Bangkok City's Infrastructure, a view! |
Now it’s the only sane way I know to manage infrastructure. No more clicking around AWS or GCP like it’s 2012.
Here’s the shortest path to getting productive without drowning in IaC philosophy.
1. Install three things
- Terraform.
- AWS CLI (or gcloud).
- A folder you won’t abandon.
2. Start with the smallest possible main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "ap-southeast-1" # choose nearest one to your users
}
resource "aws_s3_bucket" "app" {
bucket = "my-terraform-demo-bucket"
}
Keep it boring. Boring infra is stable infra.
3. Run Terraform’s holy trilogy
terraform init terraform plan terraform apply
Init downloads what you need.
Plan tells you what’s about to happen.
Apply is what changes your infrastructure's actual state.
That’s most of Terraform.
4. Add variables when repetition creeps in
variable "region" {
default = "ap-southeast-1"
}
Then:
provider "aws" {
region = var.region
}
5. Add a .gitignore before you leak your entire cloud
.terraform/ *.tfstate *.tfstate.* *.tfvars *.tfplan
State files are radioactive. Never commit them.
6. Use outputs so you stop clicking around consoles
output "bucket_name" {
value = aws_s3_bucket.app.bucket
}
Terraform prints what you need. No detective work.
7. The “init -upgrade”
Whenever you add a new provider, run this immediately:
terraform init -upgrade
This is not optional. Terraform will instantly warn you. This is how you avoid Terraform’s mood swings.
Real example from my setup:
I added the null provider:
terraform {
required_providers {
null = {
source = "hashicorp/null"
version = "~> 3.0"
}
}
}
And used it for a tiny bootstrap step:
resource "null_resource" "bootstrap" {
provisioner "local-exec" {
command = "echo hi"
}
}
Terraform immediately yelled:
Error: Inconsistent dependency lock file provider registry.terraform.io/hashicorp/null: required by this configuration but no version is selected
Translation:
“You added a provider. It’s not in .terraform.lock.hcl.
I refuse to do anything until you fix this.”
The fix:
terraform init -upgrade
It pulls the provider, updates the lock file, and Terraform stops sulking.
8. Manage all providers with Terraform
Whenever you need to setup your infrastructure weather it's Public Cloud like AWS, GCP or external tools like New Relic, Rollbar, whatever. Terraform got you covered.
That’s the real power here. One workflow. One config. One state file. Everything managed the same way. Let me know, how far you can take this setup? Happy to hear from fellow terraform devs.
9. Grow slowly, not heroically
Start tiny. Add resources one at a time.
Split files when things get crowded.
Terraform rewards momentum, not architecture diagrams.
The Point
Terraform isn’t “DevOps tooling.”
Terraform is “please don’t break production at 2 A.M.” tooling.
For solo founders, it gives you:
- Reproducible infra
- Real version control
- Zero mystery changes
Start small. Keep it clean. Let Terraform scale with you. Now go build and conquer the world!
No comments:
Post a Comment