liveBook · Manning

Domain-specific language

As explained in Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

A language designed to express concepts and operations within a particular application or problem domain.

A domain-specific language (DSL) expresses infrastructure resources through a higher-level configuration format, commonly YAML or JSON, rather than a general-purpose programming language. section 2.3.2

DSL-based infrastructure requires tooling that validates syntax, enforces formatting, and checks configuration values before deployment. Linting rules can also enforce security standards and run through Git hooks or continuous delivery workflows. section 2.3.2

Testing a Terraform DSL configuration

Store a network definition as Terraform-compatible JSON, then use pytest to parse the file and check the network name, subnet count, and IP address ranges. Generate a Terraform dry run when required values appear only after planning, and parse its JSON output without deploying resources. section 6.2.2

How Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform covers it

How deep it goes
Defines DSL abstraction and demonstrates configuration testing, but does not explain DSL implementation internals.
Examples
Uses Terraform-compatible JSON, pytest tests, Terraform plans, CloudFormation YAML, and formatting or linting commands.
What you can do after
Apply it via Terraform or CloudFormation, then validate, format, lint, and unit-test configurations before deployment.
How it connects
Connects DSLs with infrastructure as code, Terraform, CloudFormation, Bicep, Ansible, Puppet, and Chef.

Also explained in

Compare how 10 books explain domain-specific language →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform. The section links point to the parts of the book it draws on.