Terraform AWS Tutorial: Your First Resource
Hands-on Terraform from zero to applied. The fastest path to understanding what state, plan, apply mean.
Step 1: Install Terraform
brew install terraform (macOS); verify with terraform version.
Have AWS credentials configured (aws CLI works).
Step 2: Write configuration
resource "aws_s3_bucket" "learn" { bucket = "tf-learn-$(uuid)" }- Save as
main.tfin a fresh directory.
Step 3: Plan and apply
terraform init, downloads providers.
terraform plan, shows what will change.
terraform apply, creates the bucket.
Step 4: Destroy
terraform destroy, tears down.
Inspect: terraform state list, what Terraform manages.
Cleanup: rm -rf .terraform terraform.tfstate* when done.
Antipatterns
- Skipping plan. Apply blindly is dangerous.
- Committing tfstate to git. Use remote state.
- Hard-coded names. Use random_id or variables.
What to do this week
Three moves. (1) Run the tutorial end-to-end on your own laptop / sandbox. (2) Apply the pattern to one production workload. (3) Document the variations you needed; share with the team.