What carries over
| Cloud skill | Terraform equivalent | Why it still matters |
|---|---|---|
| Infrastructure as Code (IaC) mindset | Terraform configuration files (*.tf) |
You already treat resources as declarative definitions; Terraform just formalizes the syntax and state handling. |
| Resource lifecycle awareness |
create, update, delete phases in the plan/apply cycle |
Your experience with provisioning APIs (e.g., aws ec2 run-instances) maps directly to Terraform’s three‑step workflow: terraform init, terraform plan, terraform apply. |
| Tagging / labeling conventions |
tags or labels blocks in resources |
Tag strategies you enforce for cost allocation, security, and monitoring are expressed the same way, only inside HCL. |
| IAM / least‑privilege principles | Provider‑level credentials and per‑resource iam_* arguments |
The same security posture applies; you’ll just declare it in code rather than via console clicks. |
| Version control for configs | Store .tf files in Git, use PRs for changes |
Your Git workflow (branch, review, merge) stays unchanged; Terraform adds terraform fmt and terraform validate as pre‑commit checks. |
| Stateful services awareness | Remote state backends (S3, GCS, Azure Blob) | You already know about durable storage for secrets; remote state is just another bucket with locking enabled. |
| Idempotent operations |
terraform apply is safe to re‑run |
Your CI pipelines already assume repeatable deployments; Terraform guarantees no drift when the plan shows “no changes”. |
| Monitoring & observability hooks |
lifecycle meta‑argument, prevent_destroy
|
The same operational guardrails you set in cloud consoles become explicit in HCL. |
| Rollback strategies |
terraform destroy or terraform apply -target
|
You already use snapshots or previous AMIs; Terraform lets you revert by applying a prior configuration or destroying resources. |
What's new
Side‑by‑side example: creating a single S3 bucket
AWS Console / CLI
aws s3api create-bucket --bucket my‑app‑bucket --region us-east-1
aws s3api put-bucket-tagging --bucket my‑app‑bucket --tagging 'TagSet=[{Key=Environment,Value=dev}]'
Terraform
provider "aws" {
region = "us-east-1"
}
resource "aws_s3_bucket" "app_bucket" {
bucket = "my-app-bucket"
tags = {
Environment = "dev"
}
}
What changed and why
- Declarative vs imperative – The CLI commands are imperative (you tell AWS what to do now). Terraform describes the desired state and lets the engine compute the actions.
-
Single source of truth – All bucket properties live in one
aws_s3_bucketblock; you no longer maintain separate scripts for creation, tagging, and policy updates. - State tracking – Terraform records the bucket’s ID, ARN, and any computed attributes in a state file, enabling safe updates and drift detection.
-
Plan before apply –
terraform planshows exactly what will happen (create, modify, or no‑op) before any API call is made, reducing accidental changes. -
Modularity – The same block can be referenced elsewhere (
aws_s3_bucket.app_bucket.arn) without hard‑coding strings, supporting DRY principles.
Common pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Managing state locally | Lost work after a laptop crash, or “resource already exists” errors. | Move state to a remote backend (e.g., terraform { backend "s3" { bucket = "tf-state" key = "prod/terraform.tfstate" region = "us-east-1" } }) and enable state locking. |
| Hard‑coding IDs | Config drifts when resources are recreated; aws_instance.example.id changes but code still points at the old ID. |
Reference resources via their Terraform address (aws_instance.example.id) instead of copying output values manually. |
| Mixing providers without version constraints | Unexpected provider upgrades break plans. | Pin provider versions in the required_providers block and run terraform init -upgrade only when you intend to test a new version. |
Ignoring terraform fmt / validate |
Inconsistent formatting leads to noisy diffs; syntax errors cause plan failures. | Add these commands to pre‑commit hooks or CI pipelines. |
Over‑using count for conditional resources |
Resources are created with empty names or unexpected duplicates. | Prefer for_each with a map of enabled resources; it gives explicit keys and easier removal. |
Neglecting lifecycle meta‑arguments |
Accidental deletion of critical resources during a refactor. | Use prevent_destroy = true on resources that must never be destroyed by Terraform. |
Assuming terraform apply is instant |
Large plans appear to hang; you think the CLI is broken. | Understand that Terraform may be waiting on provider rate limits or eventual consistency; use -parallelism to tune concurrency if needed. |
| Storing secrets in plain text |
*.tf files committed with API keys. |
Use environment variables, terraform.tfvars excluded via .gitignore, or secret managers (e.g., aws_secretsmanager_secret_version). |
Your 30‑day plan
Week 1 – Foundations
- Install Terraform (latest stable) and configure a remote backend (S3 + DynamoDB lock).
- Complete the official Getting Started tutorial: create a VPC, two subnets, and an EC2 instance.
- Write a
README.mddescribing the project layout (modules/,env/,providers.tf). - Mini‑project: Build a single‑region S3 bucket with versioning and a lifecycle rule; store the bucket name in an output variable.
Week 2 – Modules & Reusability
- Refactor the Week 1 VPC into a reusable module (
modules/vpc). - Learn
for_eachanddynamicblocks by creating a module that provisions a set of security‑group rules from a map variable. - Integrate
terraform fmtandterraform validateinto a Git pre‑commit hook. -
Mini‑project: Deploy a multi‑AZ RDS instance using the official
terraform-aws-modules/rds/awsmodule, overriding only the engine and instance class.
Week 3 – Environments & CI/CD
- Set up separate workspaces or directories for
devandprod(e.g.,env/dev,env/prod). - Use
terraform plan -out=plan.outandterraform apply plan.outin a CI pipeline (GitHub Actions or GitLab CI). - Implement a simple policy check with
terraform validateandtflint. -
Mini‑project: Deploy a serverless API using API Gateway + Lambda (use the
aws_lambda_functionresource) and expose the endpoint via a custom domain.
Week 4 – Advanced Topics & Polish
- Explore data sources to import existing resources (e.g.,
aws_amidata source). - Add
lifecycleblocks (prevent_destroy,ignore_changes) where appropriate (e.g., for IAM roles you manage outside Terraform). - Document the entire codebase with a
docs/folder, including a diagram generated byterraform graph. -
Capstone project: Build a complete three‑tier web app (VPC, ALB, ECS Fargate service, RDS) using a combination of custom modules and community modules, and deploy it to both
devandprodenvironments via the CI pipeline.
FAQ
How do I migrate an existing manual setup to Terraform?
Import each resource with terraform import <address> <id> and then run terraform plan to fill the configuration files; commit the resulting HCL and keep the state remote.
Do I need to learn a new programming language?
Terraform uses HCL (HashiCorp Configuration Language), which is declarative and purpose‑built for IaC; it’s not a general‑purpose language, so the learning curve is modest for seasoned developers.
Can I mix Terraform with my existing CloudFormation or ARM templates?
Yes, but keep them isolated: use separate state files and avoid managing the same resource in both systems to prevent drift.
What’s the best way to handle secrets in Terraform?
Never hard‑code secrets. Use environment variables (TF_VAR_ prefix), encrypted files (.tfvars encrypted with GPG), or reference secret manager services via data sources (e.g., aws_secretsmanager_secret_version).
Keep going
- See what already transfers: take the free Cloud → Terraform readiness check
- Related: Node.js developer learning Python: what carries over, what's new, 30-day plan
- Related: Spring Boot developer learning Express: what carries over, what's new, 30-day plan
Originally published at switchbyskill.com.
Top comments (0)