Learn why an apply can differ from a prior plan when teammates modify resources after planning. This explains the role of the state file, drift, and why up-to-date plans plus clear team communication are key to preventing surprises during apply, especially in collaborative setups.

Multiple Choice

If a teammate modifies an infrastructure component you are working on after you ran terraform plan, will the apply plan remain the same?

When a teammate modifies an infrastructure component after you have run `terraform plan`, the apply plan will differ. This difference arises because Terraform generates a plan based on the current state of the infrastructure as recorded in the state file and the desired configuration that you specify in your Terraform files. If any changes are made to the infrastructure after the `terraform plan` command is executed, those changes won't be reflected in the state file until you apply them. When you run the `terraform apply` command, Terraform recalculates the current state compared to the desired state defined in your configuration. If there have been any modifications in the actual infrastructure, the apply will detect those changes and may produce a different outcome than what was presented in the initial plan. These changes may include updates made by your teammate or external changes that were not initiated through Terraform. Therefore, it is crucial to communicate with team members and ensure that everyone understands the current state of the infrastructure and any changes made to it before running the `terraform apply`. This practice helps to avoid unexpected results or conflicts. The other options imply a static relationship between the plan and the current state or enable misinterpretations of changes, which does not account for the dynamic nature of infrastructure managed by Terraform.

If you’re charting your Terraform journey, you’ll soon bump into a simple, stubborn truth: the moment someone else touches the infrastructure after you’ve run plan, that plan can’t stay the same. Terraform’s magic—turning code into steady, living resources—depends on a shared sense of what’s supposed to exist right now. When reality drifts, the plan drifts too. Let’s unpack why that happens and how teams can navigate it without chaos.

The core idea: plan vs. reality, with drift in between

Imagine you write a set of instructions for building a tiny village in the cloud. You run a plan, which is like a rehearsal script. Terraform looks at two things: the state it already knows—what’s currently deployed, as recorded in the state file—and the configuration you’ve written in your files—the forest of desired resources. The plan tells you, “Here’s what Terraform will do to move the current state toward the desired state.” It’s a carefully constructed sequence: create this, delete that, modify this other thing.

But the village in the real world isn’t static. A teammate might tweak a server size, a security group rule, or a network route after you’ve done your rehearsal. Those changes aren’t instantly reflected in the state file until you call apply. When you do, Terraform re-evaluates: what actually exists, what you want, and what needs to change to reconcile the two. If the actual infrastructure has drifted, the apply will reveal differences—sometimes large, sometimes tiny—that weren’t visible in the original plan.

That’s why the answer isn’t “the plan stays the same.” The plan can become outdated the moment someone else nudges infrastructure in a different direction.

Drift happens in the wild—and what that means for teams

Drift is everywhere when multiple hands touch the same environment. A person might:

  • Update an instance’s machine type for performance, forgetting to run Terraform immediately.

  • Change a security group rule to fix an urgent access issue.

  • Spin up a new resource manually, outside of Terraform, to test a feature or debug a problem.

Each of these moves creates a gap between what Terraform thinks is true (the state) and what’s actually true in the cloud. When you run a plan, Terraform looks at that gap. If the gap exists because someone changed something directly, the plan you see is a forecast of how Terraform would bring the actual state back in line with the configuration. In practice, that forecast often differs from what you saw before—the plan is dynamic, not static.

A practical way to think about it: your plan is a snapshot of intent, not a guarantee

Plan is permission to act, not a commitment that everything will stay exactly as planned. It’s a snapshot of intent based on the moment you ran it. The real, living environment continues to change, especially in fast-paced teams and production-like environments. That’s not a flaw—it’s the nature of modern infrastructure, which grows with evolving needs and rapid experimentation.

What happens when you actually apply after drift

When you run terraform apply after drift has occurred, Terraform re-reads the current state and compares it to the desired state. If there were changes not captured in your code (or changes made by teammates), Terraform will propose a new set of actions to reconcile. Sometimes it will simply apply the exact changes you anticipated; other times it will reveal surprises—like a resource modification you didn’t expect, or a dependency that now needs reordering.

In practice, this means you should expect the apply to reflect the real, observed state, not a flawless mirror of the initial plan. The reconciliation step is where the rubber meets the road, and it’s exactly why coordination is essential in teams.

Strategies to minimize surprises and keep everyone on the same page

You don’t have to live with chaos. There are practical patterns that help teams stay aligned, even when changes happen outside Terraform.

  • Use a shared, authoritative state store

Remote backends—like Terraform Cloud, S3 with DynamoDB locking, or other state backends—provide a single source of truth. They prevent conflicting writes and help you see who touched what, when. In a team setting, that shared state is your first defense against drift turning into a surprise.

  • Lock the state during operations

State locking prevents more than one person (or process) from mutating the same resources at the same time. It’s the Terraform equivalent of locking a door while you’re painting. If someone else starts a plan or apply while you’re mid-flight, they’ll get a clear message that the state is temporarily unavailable. It’s not glamorous, but it saves a lot of headaches.

  • Enforce change through code review and CI/CD

Treat infrastructure like code—because it is. Use pull requests, required reviews, and automated checks before anything lands in your environment. A centralized pipeline can run terraform plan and show what would change, allowing teammates to catch drift before it becomes a problem. It’s not about policing; it’s about visibility and shared understanding.

  • Embrace drift detection and periodic reconciliation

Tools and workflows that routinely compare actual resources to state help surface drift early. A simple nightly reconciliation or a lightweight drift check can alert you to changes that slipped through the cracks. Consider adding a policy that any drift must be reconciled via Terraform rather than manual tweaks.

  • Document ownership and runbooks

Clear accountability matters. If someone owns a service, they should own how it’s deployed and updated in Terraform. Quick runbooks for common drift scenarios—like what to do if a resource was manually adjusted—keep your team calm and efficient when things aren’t exactly as planned.

  • Practice explicit change management for critical components

For high-stakes resources (production networks, shared databases, or security-critical elements), introduce tighter controls. Require dual confirmation for changes, or implement approval gates in your CI/CD to ensure the plan aligns with the intended state before applying.

A few real-world analogies to keep it relatable

Think of Terraform as a chef’s recipe book for your kitchen of cloud resources. You jot down your recipe (the configuration), check what’s already on the stove (the state), and then plan how to cook everything to perfection. If a sous-chef adds extra salt to the soup (drift), your planned plating changes because you now have to adjust the timing, temperature, or even ingredients to keep the dish consistent. When you plate (apply), you reassess and adapt to the current taste. The goal isn’t to rigidly hold to the first version of the recipe; it’s to ensure the final dish matches what you intend to serve, given what actually happened in the kitchen.

Common pitfall scenarios and how to handle them gracefully

  • Scenario: A teammate changes a resource directly in the cloud console.

What happens: The plan you ran earlier is no longer in sync with reality. The apply will show differences that reflect the drift. You’ll need to either adjust your configuration to reflect the reality or revert the change in the cloud and re-run plan/apply.

  • Scenario: You forget to push a local change and someone else applies

What happens: Your local changes might not be represented in the remote state yet. The subsequent plan may reveal a different path to convergence, sometimes requiring a pull, merge, and re-run to align the desired state with what’s deployed.

  • Scenario: A minor tweak becomes a bigger drift in a complex setup

What happens: Small configuration differences can cascade—dependency chains, module outputs, and variable values interact in surprising ways. That’s where the plan’s value shines: it highlights what Terraform intends to do after considering the actual state. If you see unexpected steps, pause, review, and synchronize with your team.

A thought on the evolution of infrastructure tooling

As teams grow, the tools themselves evolve—Terraform Cloud and Terraform Enterprise bring collaboration features that make this dance smoother. They’re designed to help teams coordinate changes, share a single truth about the environment, and provide governance without slowing down innovation. It’s not about heavy-handed control; it’s about predictable, observable changes that you can reason about together.

Keeping your mental model sharp

Here are a few takeaways to keep in mind, without overthinking the mechanics:

  • Plan is a forecast based on the current state and desired configuration. It’s a guide, not a guarantee.

  • Drift happens when the real world diverges from the state file. It’s normal in collaborative environments.

  • Apply reconciles the actual state with the desired configuration—often revealing changes you didn’t expect.

  • Collaboration, backends, locking, and disciplined workflows reduce surprises and create a smoother path from plan to reality.

A gentle reminder: stay curious, stay communicative

Infrastructure is collaborative by nature. The moment your team embraces visibility over vanity, the drama of drift subsides. You’ll still get those satisfying moments when Terraform applies cleanly and your environment hums along as intended. And when it doesn’t, you’ll know you’re in good company—systems are living things, after all, not static objects carved in stone.

If you’re exploring Terraform further, keep experimenting with small, isolated components first—it makes drift a lot less intimidating. Play with modules, try different backends, and observe how the plan and apply interplay. Before you know it, you’ll be reading your environment like a story: the configuration is the plot, the state is the manuscript, and the apply is the moment the story reaches its next chapter. And that’s where the real satisfaction lives—the moment when your infrastructure behaves exactly as it should, even as the world around it keeps evolving.