The difference between instructions and desired state

Two teams build equivalent online-service environments, one with a procedure that creates resources in sequence and the other with a description of the infrastructure that should exist. Both methods work until a production server fails and an emergency replacement creates a mism…

A regional retailer runs the same online service in two environments. One team builds its infrastructure by following a script that creates a network, starts three servers, and connects them to a load balancer. Another team uses a configuration that describes the network, the required server capacity, and the connections that should exist. On an ordinary morning, both environments appear identical. During an emergency replacement of a failed server, however, the teams get very different results. The first script tries to create another set of resources. The second tool proposes several changes, including removing a machine that an operator added temporarily. Both approaches can automate infrastructure. Neither should be trusted until the team understands what each will do to the system that already exists.

This example introduces a useful distinction between instructions and desired state. An imperative procedure describes the operations to perform: create a resource, configure it, attach it, and start it. A declarative configuration expresses the target condition, leaving the tool to determine which supported actions can move the environment toward that condition. These are descriptions of approaches, not guarantees about safety. A carefully written procedure can check what already exists and avoid repeating work. A desired-state tool can propose an unexpected deletion if its configuration no longer includes a resource that the tool believes it manages. The question is what the operator can predict, review, and safely repeat when actual infrastructure differs from the original design.

For optional follow-up after listening, the AutoOps+ Study Guide from Bare Metal Cyber offers another way to examine infrastructure as code and idempotency. Imagine the same deployment being requested twice by mistake. The important question is what state the second run would leave behind, not whether the method has been labeled declarative or imperative. Try explaining when a repeated operation should make no change and what evidence you would want before permitting a resource to be replaced.

Follow the first team during a normal deployment. Its script creates a network and a group of servers in a particular order. A fresh environment is simple: nothing exists yet, and every creation step has a clear purpose. The script may work reliably under those initial conditions. Now run it again against an environment that has been serving customers for months. If the script blindly repeats creation, it may fail because names are already taken, or it may create duplicates with new identities. If it assumes that an existing network is correct without checking, it may also leave a dangerous rule untouched. An imperative approach needs deliberate checks and recovery behavior to remain safe during repeated operation.

Idempotency describes an operation whose repeated execution under the same relevant conditions has the same resulting effect as executing it once. Consider an automation that ensures a service is running. Once the service is running, repeating the task should not keep making unnecessary changes. Compare that with an operation that adds another server every time it runs. The latter intentionally creates a new result on each execution unless the author introduces logic that limits it. Many configuration-management modules aim for idempotent behavior by inspecting current state before changing it. But a framework cannot make every custom step idempotent by magic. Side effects such as sending a notification, issuing a new token, or appending a firewall rule may require special care.

The second team uses infrastructure as code. Its configuration describes what resources should exist, how they relate, and some of their required settings. A tool such as Terraform can compare that configuration with its recorded understanding of managed resources and information obtained from the infrastructure provider. It then proposes a plan of actions to bring managed infrastructure toward the target. The team can review the proposed changes before authorizing execution. That comparison is powerful because the configuration has a longer life than a one-time creation sequence. It provides a versioned statement of intended infrastructure and an opportunity to discuss change before the tool performs it.

But the configuration is only part of the evidence. A desired-state tool often maintains state information that associates configuration objects with real resources. In Terraform, state supports tracking and planning of managed objects. Losing, exposing, or conflicting over that state can create operational problems. A team should protect access to its state storage, coordinate updates, and follow its chosen backend's rules for locking or concurrency. State can also contain sensitive information, so it should not be treated as a harmless debugging attachment. The operator needs to understand which resources are managed, which remain outside the tool, and how the stored record relates to the live environment.

The retailer's emergency illustrates why that last distinction is important. A server fails during a major sale. An on-call engineer creates a temporary replacement directly through the infrastructure provider to restore service quickly. Customers can buy again, but the new server is not represented in the version-controlled configuration or the tool's managed state. During the next scheduled change, the desired-state workflow cannot simply assume that every useful live resource is safely represented by the repository. Depending on what the tool manages and how the replacement was created, it might ignore the temporary server, propose conflicting changes, or attempt to remove a managed object whose recorded role no longer matches reality. The operator must reconcile the emergency work with the long-term design before accepting the plan.

This difference is often called drift: the live infrastructure has diverged from the declared or recorded arrangement. Drift is not automatically evidence of a mistake. An emergency fix may be authorized and necessary, while an undocumented permanent exception may be dangerous. A planned state comparison gives the team a way to notice differences, but noticing them is only the beginning. The team must decide whether to adopt the emergency change into the intended design, reverse it after the emergency, or replace it through a controlled transition. Letting a reconciliation tool choose the business answer simply because it can compute a technical action would confuse implementation with authorization.

Imagine the plan proposes deleting a network connection that currently carries payment transactions. The configuration says that connection should no longer exist, perhaps because it was removed during a cleanup. The operator should ask whether that resource is still required, whether the tool's state accurately identifies it, and what dependent systems would lose access if it disappeared. A plan can show anticipated operations, sometimes including replacements that are more disruptive than minor configuration edits. It is not an independent approval of those operations. The review has to connect technical changes with service dependencies, customer impact, and the permitted maintenance window.

The same principle applies when the plan proposes no changes. That result may indicate the managed environment matches the tool's known target. It does not establish that the target is secure, cost-effective, or even appropriate for the business. A mistaken configuration can be reproduced perfectly. A machine could have the exact intended firewall rule and still expose a service that should have been private. Infrastructure as code makes change repeatable and reviewable, but the correctness of the desired state depends on requirements, design, tests, and the people authorized to approve it.

For a scenario exercise in Bare Metal Cyber's Cyber Challenge practice, consider three facts together. The retailer needs capacity restored immediately, an emergency server was created outside the normal workflow, and the next plan proposes deleting an older machine. Decide what you would verify before any automated reconciliation. You are practicing the boundary between describing infrastructure and authorizing its changes. The most important answer is an explanation of the dependency and recovery risks, not a command to type into a terminal.

A declarative tool also has limits in what it can observe or control. Some resources are outside its provider integration. Certain settings may be computed by a platform, changed by a separate service, or modified after creation. A team may manage the network with one system and the application configuration with another. Each system has its own scope and authority. If two independent controllers continually try to impose conflicting values, the environment can oscillate between configurations or produce repeated failures. Before automating reconciliation, establish which system owns each important property and how exceptions are handed off.

The first team does not have to abandon its procedure-based automation to improve safety. It can check whether a resource exists before creating it, compare the existing settings with approved requirements, and make only the necessary change. It can record the exact objects it altered and stop on conditions it cannot interpret safely. It might use an imperative script for a temporary restoration task that requires careful sequencing and human authorization. The classification of a method does not determine whether it can be made reliable. The design of its checks, boundaries, and recovery behavior determines how it performs under repeated and interrupted execution.

Declarative tools likewise perform operations in some order underneath their configuration language. A provider may need a network before it can create a server inside that network. An application may depend on a database that cannot be safely replaced while transactions are in progress. Declaring the target does not remove those dependencies or the risk of partial failure. A tool may complete some changes and then stop because a later action failed. The next run must reason from the resulting environment rather than pretend the entire change was atomic. Operators should understand what has already happened, what remains incomplete, and whether repeating the plan could affect live traffic.

Some teams misunderstand version control at this stage. They believe that restoring yesterday's infrastructure configuration will automatically put yesterday's environment back. Reverting a file changes the declared target. The tool may still need to recreate resources, replace objects that cannot be modified in place, or remove new resources whose data is now valuable. A restored configuration cannot recreate lost transactions or recover an identity that was revoked externally. A rollback plan needs to account for persistent data, dependencies, and externally visible effects. For high-impact systems, the team should evaluate restoration paths before the first change, not after the proposed reversal starts deleting live resources.

Policy checks can help constrain both styles of automation. An organization may prohibit public exposure of internal services, require approved network segments, or insist that destructive changes receive an additional approval. Those conditions can be tested against plans, configurations, or observed resources using appropriate tooling. Yet there is still a difference between a rule being syntactically satisfied and the entire change being operationally safe. A replacement server might meet every approved configuration setting while arriving without application data or a working integration. Configuration review should therefore be paired with tests of the service behavior that the infrastructure is supposed to support.

The emergency engineer now has a sensible path forward. The team records why the temporary server was created, verifies what traffic and data depend on it, and determines whether it belongs in the long-term design. It reviews the managed resources and planned changes, resolves any mismatch in ownership or state under a controlled process, and schedules potentially disruptive replacements at an acceptable time. The temporary machine may be adopted into the managed arrangement, replaced by a correctly declared resource, or retired after traffic is transferred. The right choice depends on the live dependencies and business need, not on a philosophical preference for one automation style.

One more condition changes the decision. Suppose the system is a short-lived test environment that can be discarded after every run. An imperative procedure that creates a fresh set of resources may be perfectly sensible if it also destroys the old environment under a clear cleanup policy. In a production environment carrying durable customer data, the same assumption would be reckless. A desired-state approach might be attractive because it makes long-lived infrastructure easier to compare and govern, yet its destructive changes would still require careful review. The design should fit the cost of a mistake, the lifespan of the resources, and the ability to recover, rather than treating one approach as universally superior.

The distinction to remember is grounded in the question each system answers. A procedure tells the automation which operations to attempt and in what sequence. A desired-state configuration tells a reconciliation tool what the managed environment should look like, then asks it to work out the necessary operations. Either can be built with careful boundaries or unsafe assumptions. The responsible operator examines actual state, desired outcome, authority, dependencies, and side effects before approving an action. That reasoning is what allows infrastructure as code to remain useful after the first successful deployment, when real systems begin to change in ways their original authors did not anticipate.

The difference between instructions and desired state
Broadcast by