Join us for live office hours! Next WednesdayNext Wed
Terraform State
← Back to Glossary
Infrastructure as Code

What is Terraform State?

Terraform state is a file that maps real-world resources to your configuration, tracks metadata, and enables Terraform to determine what changes need to be applied to reach the desired state.

How Terraform State Works

When Terraform creates or modifies resources, it records the mapping between configuration and real-world resources in a state file. This file is essential for Terraform to know what it manages and to calculate the difference between desired and actual state.

By default, state is stored locally in terraform.tfstate. For team use, state should be stored in a remote backend like S3 with DynamoDB locking.

Why State Matters

  • Resource tracking — Terraform needs state to know which real resources correspond to which configuration blocks
  • Performance — state caches resource attributes to avoid querying the provider API for every plan
  • Dependency resolution — state records resource dependencies for correct ordering of operations

Remote State Best Practices

  • Store state in S3 with versioning and encryption enabled
  • Use DynamoDB for state locking to prevent concurrent modifications
  • Separate state files per environment and component to limit blast radius
  • Never commit state files to Git—they may contain sensitive data

Drift Detection

State drift occurs when real infrastructure changes outside of Terraform (manual console changes, other tools). Regular terraform plan runs detect drift by comparing state against actual infrastructure. Automated drift detection pipelines can alert teams to unauthorized changes before they cause issues.

Related Terms

TerraformTerraform ModulesDrift Detection

Related Articles

The Role of Open Source Module Libraries in a Post-AI World

Open source Terraform module libraries are infrastructure's equivalent of npm and PyPI—battle-tested foundations that become even more critical when AI enters the picture.

Feb 17 2026

Own Your Infrastructure

AI leveled the playing field. You don't need vendor platforms anymore. Here's what real infrastructure ownership looks like and why it's your strategic advantage.

Feb 15 2026

Why Terraform Is More Relevant Than Ever in the AI Era

Generative AI doesn't replace infrastructure as code—it supercharges it. Here's why IaC is the perfect foundation for agentic development.

Jan 28 2026

Service-Oriented Terraform: Why the Patterns That Work for Software Work for Infrastructure

Infrastructure as Code follows the same architectural principles software engineering established decades ago. Here's why service-oriented patterns aren't workarounds—they're the right way to build.

Nov 30 2025

Building Enterprise-Grade Terraform: A Practical Guide

Ready to build enterprise-grade Terraform? This guide covers the architectural patterns, governance frameworks, and practical implementation steps that successful teams use to balance compliance with team autonomy.

Nov 15 2025

The Production Ready Newsletter

Build Smarter. Avoid Mistakes. Stay Ahead of DevOps Trends That Matter.

The fastest way to achieve SOC 2 on AWS with Terraform and GitHub Actions.

For Developers

  • GitHub
  • Documentation
  • Quickstart Docs
  • Resources
  • Read our Blog

Community

  • Join Office Hours
  • Join the Slack Community
  • DevOps Podcast
  • Try our Newsletter

Company

  • Services & Support
  • AWS Migrations
  • Pricing
  • Book a Meeting

Legal

  • Terms of Use
  • Privacy Policy
  • Disclaimer
  • Cookie Policy
Copyright ©2026 Cloud Posse, LLC. All rights reserved.