Terraform Essential Training: State Management and Backends
3h 30mIntermediate2026-06-22
Authors

Mattias Fjellström
Course details
Confidently manage infrastructure with Terraform state and remote backends. In this course, join Terraform evangelist Mattias Fjellström as he equips you with the skills you need to confidently manage state files and state backends in real-world Terraform deployments. Discover why the state file matters, what critical data it holds, how to safely manipulate its contents, and how to recover from common state-related issues. Dive into configuring secure remote backends across major cloud providers to support collaborative Terraform workflows. An ideal fit for platform and DevOps engineers, cloud engineers, and cloud architects, this course prepares you to safeguard your infrastructure, maintain consistency, and optimize workflows with Terraform state best practices.
Learning objectives
Define the purpose of the Terraform state file, describe what it typically contains, and explain what information is not stored in state.
Configure a secure Terraform remote state backend with proper access control, encryption, versioning, and backups.
Manage and structure Terraform state backends at scale for large environments.
Manipulate the contents of a Terraform state file by importing resources, moving, and removing resources in a safe and controlled manner.
Prevent sensitive data from ending up in the state file using ephemeral resources.
Troubleshoot common Terraform state issues including handling resource state drift.
Learning objectives
Define the purpose of the Terraform state file, describe what it typically contains, and explain what information is not stored in state.
Configure a secure Terraform remote state backend with proper access control, encryption, versioning, and backups.
Manage and structure Terraform state backends at scale for large environments.
Manipulate the contents of a Terraform state file by importing resources, moving, and removing resources in a safe and controlled manner.
Prevent sensitive data from ending up in the state file using ephemeral resources.
Troubleshoot common Terraform state issues including handling resource state drift.
Concepts
Introduction
- Keeping Terraform deployments consistent and reliable with state and backends
- Course tips and set up
How Terraform State and Backends Ensure Reliable Deployments
- Why Terraform state matters for your infrastructure
- Explore what s inside a Terraform state file
- State backends in Terraform
- Compare local vs. remote state backends
- Challenge - Parse information from a state file
Configuring State Backends
- Using the local backend
- Choosing a remote backend
- Authenticating to a remote backend
- State locking for remote backends
- Challenge - Configure and use a PostgreSQL remote backend
- Solution - Configure and use a PostgreSQL remote backend
Managing State Files at Scale
- Managing Terraform state at scale
- State and Terraform workspaces
- Partial backend configuration
- Organizing multiple state files in a backend
- Migrating between state backends
- Sharing state between Terraform configurations
- Challenge - Migrating state files between backends
- Solution - Migrating state files between backends
Terraform State Manipulation
- Understanding state manipulations
- Resource addressing in the state file
- Interacting with the state file using the Terraform CLI
- Moving a resource to a new address in the state
- Removing a resource from the state
- Importing a resource to the state
- Bulk-import resources using Terraform search
- Moving a resource between Terraform configurations
- Challenge - Refactoring a state file
- Solution - Refactoring a state file
Securing the Terraform State File
- Methods to secure the state file
- Network security
- Authorization - RBAC and ABAC
- Encrypting the state file
- Versioning the state file
- Configure backups and prepare for disaster recovery
- Keep secrets out of state using ephemeral values and write-only arguments
- Challenge - Ephemeral values and write-only arguments to remove secrets from state
- Solution - Ephemeral values and write-only arguments to remove secrets from state
Troubleshooting State File Issues
- Handle state file locking issues
- Backend authorization errors
- Managing resource drift
- Recover a lost state file
- Challenge - Remediate resource drift
- Solution - Remediate resource drift