liveBook · Manning

Configuration

As explained in Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

Configuration is a declarative specification of infrastructure resources, their properties, and their relationships.

A configuration describes the infrastructure to create and how its parts relate. Rather than specifying a launch order, you define resources and use values from one resource to configure another. Terraform uses those references to infer dependencies and create resources in the required order. section 1.3.2

A web application and its dependencies

Suppose an application needs database credentials, while a DNS record needs its host’s IP address. Configure the application with values from the database and the DNS record with the host’s IP address. Those value references express the relationships: the application cannot use the database before it exists, and the DNS record needs an address from the host. section 1.3.2

Terraform configurations can be written in HCL, a human-friendly format, or JSON, which is easier to generate programmatically. Both formats describe resources, data sources, and other objects for Terraform to read. A configuration can span multiple files, and HCL and JSON files can share a directory. section 11.2

Configuration choices also affect testing and operations:

  • Test a chosen configuration by launching its resources, checking the resulting infrastructure, and tearing it down. Group checks that can run against the same deployment; use separate configurations when requirements conflict, such as private logging storage versus a public static website. section 9.2.1
  • Avoid hardcoding backend credentials in configuration. Depending on the backend, externally managed configuration files or environment variables can supply authentication; check the chosen backend’s documentation. section 6.4.4

Provider configuration has its own boundary: a provider’s schema defines which options it accepts. An API-backed provider may expose authentication parameters and allow environment variables as an alternative to setting them in the provider block. section 12.4.2

How Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu covers it

How deep it goes
Explains dependency inference, file formats, testing choices, and authentication caveats without detailing a complete configuration listing.
Examples
Uses a web application with database and DNS dependencies and contrasting private-logging and public-website storage tests.
What you can do after
Apply it via Terraform to express resource dependencies and choose distinct configurations for tests with conflicting requirements.
How it connects
Connects configuration to dependency resolution, infrastructure testing, backend authentication, and provider schemas.

Also explained in

Compare how 23 books explain configuration →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu. The section links point to the parts of the book it draws on.