Core Concepts

Objective

Understand the basics of what Terraform is, project file structure and data types.

Overview

Terraform uses a domain specific language (DSL) known as HCL. HCL is a declarative language. It describes the intended state of what needs to be provisioned/configured. Rather than tell Terraform how to configure the system, HCL says what it should be and the provisioner figures out how to do it. Terraform does not query for resources it does not know about. If a resource is created outside of Terraform it will not appear in state, plans or applies. Resources deployed outside of Terraform can often be imported if the provider supports it.

File Structure

Terraform looks for all of the .tf files in the current directory and processes them all as one configuration. Any text file with a .tf extension can be a Terraform file. By default only the current directory is evaluated. Code can be separated in to other directories using the module concept discussed later in this section. The root directory that terraform is executed against is known as the root module.

Data Types

  • string: text
  • number: any numeric representation
  • bool: true or false
  • list/tuple: an array of values that can be iterated over. [“hello”, “world”]
  • map/object: key/value representation of values {“hello” = “world}
  • null: an unquoted null value, used in conditionals and to not set specific inputs

Review

In this section we reviewed the basics of the folder structure of a Terraform project and the data types available.

Additional Reading