Terraform Variables and Outputs
Learn how Terraform input variables, local values, and output values work together to make infrastructure code reusable, readable, and easier to share across environments.
Terraform becomes much more powerful when your configuration can accept values, transform them, and return useful information. That is exactly what this section is about. Instead of hardcoding every region, instance size, environment name, or resource identifier directly in your .tf files, you can design Terraform code that is flexible and reusable.
In practice, Terraform uses three related building blocks:
| Topic | Description | Link |
|---|---|---|
| Input Variables | Accept values from users, .tfvars files, CI/CD pipelines, or parent modules so the same code can work in different environments. | Learn input variables |
| Local Values | Create named expressions inside your configuration to avoid repetition and keep logic readable. | Learn local values |
| Output Values | Return important results such as IP addresses, ARNs, and URLs after Terraform creates infrastructure. | Learn output values |
A good mental model is this:
- Input variables are what go into your configuration.
- Local values are how you organize and transform values inside it.
- Output values are what come out of it.
Together, they help you write Terraform code that is easier to maintain, easier to review, and safer to reuse across development, staging, and production.
Start with Terraform Input Variables →