Declarative programming defines the desired end state and lets an automation system determine the operations required to reach it. In infrastructure automation, configuration files describe target resources instead of prescribing every configuration step. section 25.2
Apply the pattern through a state-driven workflow:
- Write the desired infrastructure state in configuration files. section 25.2.2
- Plan the changes and verify what will be executed before applying them. section 25.2.2
- Compare the desired state with recorded current state, then apply the necessary changes. section 25.2.2
Terraform uses this model for infrastructure provisioning: Terraform Core processes HCL configuration, maintains the state file, and communicates with providers through APIs. Puppet uses a declarative DSL for configuration management, while Chef and Ansible primarily specify procedural steps. section 25.2.2 section 25.2.3
Desired service state
A Puppet resource can declare that the SSH service must be running: service { 'ssh': ensure => running, }. The declaration states the required condition without detailing the commands needed to produce it. section 25.2.3
Figure 25.6 Provisioning resources with Terraform. Configuration files are processed byTerraform Core to interact with various providers (i.e., public cloud providers) and manage infrastructure resources while maintaining state information in the state file.
Trace how configuration files pass through Terraform Core to providers while infrastructure state is maintained. section 25.2.2













