Infrastructure as Code

Infrastructure as Code and Declarative State

Model infrastructure as declarative configuration, compare desired and observed state, and let a provider execute a reviewed change toward convergence.

Beginner14 min read
Infrastructure as Code lessonDelivery and reliability foundationsLearn

Model infrastructure as declarative configuration, compare desired and observed state, and let a provider execute a reviewed change toward convergence.

What you will be able to do

  • Distinguish configuration source from desired state in a realistic infrastructure as code and declarative state case.
  • Interpret the delivery evidence and boundary associated with provider boundary.
  • Choose an appropriate action involving change preview without exceeding the named operational scope.
  • Verify converged result through an observable service result and reproducible handoff.

01

Frame Infrastructure as Code and Declarative State

Model infrastructure as declarative configuration, compare desired and observed state, and let a provider execute a reviewed change toward convergence.

A team needs one test network with a fixed name and address range. Manual console clicks have produced inconsistent copies and no reviewable history.

Keep the delivery target, declared intent, execution evidence, reliability boundary, and recovery choice separate. Start with observable state and preserve enough context for another operator to reproduce the decision.

02

Configuration source

Infrastructure as code stores intended infrastructure in human-readable versioned configuration. Within infrastructure as code and declarative state, this role answers a separate delivery or reliability question and keeps its own evidence.

Declare the test network and its address range in source files. Apply that action to the named service case before widening the rollout, infrastructure scope, or incident response.

Respect this boundary: do not treat the current console screen as the canonical definition. The observable result is specific: the repository contains one reviewable network declaration.

03

Desired state

Desired state describes the resource properties the configuration intends to manage. Within infrastructure as code and declarative state, this role answers a separate delivery or reliability question and keeps its own evidence.

Review the name and range as explicit desired values. Apply that action to the named service case before widening the rollout, infrastructure scope, or incident response.

Respect this boundary: do not confuse configuration intent with proof of current reality. The observable result is specific: the intended network state is unambiguous.

04

Provider boundary

A provider translates declared resource operations into calls to a platform API. Within infrastructure as code and declarative state, this role answers a separate delivery or reliability question and keeps its own evidence.

Select and constrain the provider that manages the network type. Apply that action to the named service case before widening the rollout, infrastructure scope, or incident response.

Respect this boundary: do not assume opentofu directly implements each platform resource. The observable result is specific: the configuration uses the expected provider integration.

05

Change preview

A plan previews actions derived from configuration, prior state, and refreshed remote observations. Within infrastructure as code and declarative state, this role answers a separate delivery or reliability question and keeps its own evidence.

Review the proposed create action and every important property. Apply that action to the named service case before widening the rollout, infrastructure scope, or incident response.

Respect this boundary: do not treat a successful preview as a completed infrastructure change. The observable result is specific: the plan contains only the intended network creation.

06

Converged result

Convergence means managed infrastructure matches the accepted declaration for the checked properties. Within infrastructure as code and declarative state, this role answers a separate delivery or reliability question and keeps its own evidence.

Apply the approved plan and inspect the resulting network attributes. Apply that action to the named service case before widening the rollout, infrastructure scope, or incident response.

Respect this boundary: do not claim full convergence from command exit status alone. The observable result is specific: the created network matches its declared name and range.

07

Apply Infrastructure as Code and Declarative State to One Service Change

Use one bounded delivery decision: A team needs one test network with a fixed name and address range. Manual console clicks have produced inconsistent copies and no reviewable history.

First, declare the test network and its address range in source files. Then, review the name and range as explicit desired values. Keep both observations attached to the exact revision, environment, or service window.

Next, select and constrain the provider that manages the network type. After that, review the proposed create action and every important property. Close the work only after you apply the approved plan and inspect the resulting network attributes.

08

Recap Before Practice and Prove

Configuration source: Infrastructure as code stores intended infrastructure in human-readable versioned configuration. In this service case, declare the test network and its address range in source files. Preserve the boundary: do not treat the current console screen as the canonical definition.

Desired state: Desired state describes the resource properties the configuration intends to manage. In this service case, review the name and range as explicit desired values. Preserve the boundary: do not confuse configuration intent with proof of current reality.

Provider boundary: A provider translates declared resource operations into calls to a platform API. In this service case, select and constrain the provider that manages the network type. Preserve the boundary: do not assume opentofu directly implements each platform resource.

Change preview: A plan previews actions derived from configuration, prior state, and refreshed remote observations. In this service case, review the proposed create action and every important property. Preserve the boundary: do not treat a successful preview as a completed infrastructure change.

Converged result: Convergence means managed infrastructure matches the accepted declaration for the checked properties. In this service case, apply the approved plan and inspect the resulting network attributes. Preserve the boundary: do not claim full convergence from command exit status alone.

NEXT STEP

Turn reading into recall

Practice the concepts without a timer, with coaching and retry available after every answer.

Open guided practice