M365Con 2027 – free online conference · 11–22 Jan 2027 · 120 sessions m365con.net

Terraform state

Concept

The record Terraform keeps of the infrastructure it manages, mapping resources in the configuration to real remote objects. Terraform uses it to decide which changes to make; it can contain sensitive values and is best kept in a remote, locked and access-controlled backend.

✦ CONCEPTTerraform stateM365.FM
Title graphic: Terraform state (Concept)

Often discussed together

Episodes about Terraform state often also cover Amazon Web Services (AWS).

Description

Terraform state is the record that Terraform keeps of the infrastructure it manages. It maps the resources described in a configuration to the real remote objects that exist in a cloud environment. Terraform reads this record to decide which changes to make: which resources to add, which to update and which to delete. Because the state acts as the source of truth for everything Terraform manages, how it is stored and protected has a direct effect on how safely deployments run.

In practice the state is held in a state file. One M365.FM episode, "Terraform vs Azure Bicep: Which IaC Tool Should You Choose?", describes Terraform as relying on a state file to track the current status of infrastructure and stresses that state management must be handled carefully to avoid issues that can disrupt deployments. The same episode notes that the state file can be stored locally or remotely, with remote options including cloud buckets and similar storage. The choice between local and remote storage is one of the central decisions around Terraform state.

Microsoft Learn documentation on storing Terraform state in Azure Storage explains why that choice matters. By default, Terraform stores state locally. The documentation describes this as a poor fit for teams, because the file may expose sensitive information, since it can contain secrets in plain text, and because there is a greater risk of accidental deletion. The recommended pattern is to keep the state remotely in an Azure Storage blob container through the azurerm backend. That backend is configured with the storage account name, the container name and a key that names the state file.

The documentation also covers how access to that storage is handled. The access key is best supplied through an environment variable rather than being written to disk, and it can also be stored in Key Vault. Azure Blob storage locks the state automatically before write operations, which prevents concurrent changes that could corrupt it, and the data is encrypted at rest. The example in the documentation uses an access key and open network access, which the page marks as unsuitable for production. For production use, it points to firewalls, service endpoints or private endpoints, together with the most secure supported authentication method.

Typical situations where state comes up include team collaboration, pipeline-based deployments and reviewing planned changes. The episode "Azure Infrastructure as Code and DevOps with Maik van der Gaag [MVP]" mentions using Terraform state files to track the current state of resources, which helps in planning and applying changes safely. It places this alongside other practices such as sharing code through Terraform modules, requiring code reviews before changes are merged, and using continuous deployment to deliver updates to an Azure environment reliably and with less risk of human error. The episode also mentions combining Terraform with tools such as Ansible or PowerShell for end-to-end automation.

Taken together, the sources point to a consistent set of practices. Terraform state should be treated as sensitive data, kept in a remote backend rather than on a local machine, protected by locking so that two operations cannot change it at the same time, and placed behind access controls. Understanding what the state contains, and who or what can read or modify it, is part of operating Terraform responsibly, particularly when several people or automated pipelines work against the same infrastructure. The same concern for state handling is one of the points the first episode raises when comparing Terraform with Azure Bicep for infrastructure as code.

Overview compiled with AI from M365.FM episodes and the facts on this page. You can improve it with the edit button below.

TypeConcept

Episodes about Terraform state

Episodes in which Terraform state is discussed:

Terraform - Simply Explained

2026-10-27 · YouTube: Terraform - Simply Explained

Terraform exists because your Azure portal clicks can't be rebuilt twice. It writes that infrastructure down as a file you can read, review, and run again. In this episode of Simply Explained you will learn: - What Infrastructure as Code Really Means - What…

Timeline of episodes about Terraform state

Articles about Terraform state (1)

Articles in which Terraform state is a topic:

Frequently asked questions

Questions marked with AI were written with AI from the facts on this page.

What is Terraform state used for? (AI)

Terraform uses its state to match the resources in a configuration with the real objects that were deployed. This tells Terraform which resources to add, update or delete when changes are planned and applied.

Why should Terraform state not be kept locally? (AI)

According to Microsoft Learn, local state is poor for teams, can expose sensitive information because the file may contain secrets in plain text, and carries a higher risk of accidental deletion. A remote backend is the recommended alternative.

How can Terraform state be stored in Azure? (AI)

The state can be kept in an Azure Storage blob container using the azurerm backend, configured with a storage account name, a container name and a key for the state file. Blob storage locks the state before write operations and encrypts data at rest.

What is the Terraform state file?

It is Terraform's memory of what it built. Remote state lets a team share it without overwriting each other. · From the episode: Terraform - Simply Explained

Glossary

Community wiki

Short info above, community knowledge below: add practical tips, examples or corrections. New contributions are reviewed first; trusted members publish directly.

Experts and companies for this topic

Nobody has listed this topic yet. Add it to your profile.

Sources

Maintained by Mirko Peters (Microsoft MVP) · Last updated: