Ravindra BagaleCourses & study guides

Chapter 12: Terraform Introduction

12.6 Variables, tfvars and outputs

File Role
variables.tf Declare knobs
terraform.tfvars / *.auto.tfvars Assign values (often gitignored for personal IPs)
outputs.tf Print useful IDs after apply
# .gitignore excerpt for Terraform labs
.terraform/
*.tfstate
*.tfstate.*
crash.log
terraform.tfvars
*.tfvars
!example.tfvars
override.tf

Ship example.tfvars with fake placeholders so teammates know keys — not your real IP.

Practice task

Write an example.tfvars with clearly fake vpc_id and my_ip_cidr values and a one-line comment that real values stay local.