Lesson 4 of 4 · Terraform Core Concepts

Outputs and state

Outputs expose useful values after Terraform applies a configuration. State is Terraform’s record of which real resources it manages. Treat state as sensitive operational data: use a secure remote backend for team or production work and do not casually edit it.

Example

output "vpc_id" {
  value       = aws_vpc.main.id
  description = "ID of the training network"
}

terraform {
  backend "s3" {}
}

Step by step

  1. Output values that another module or person needs.
  2. Mark secret outputs as sensitive.
  3. Use a remote backend for shared work.
  4. Review state changes with the same care as infrastructure changes.

Common mistakes to avoid

  • Treating an output as a secret store.
  • Deleting state to fix an infrastructure problem without understanding the impact.