Services

Resources

Company

Terraform

Terraform is an open source infrastructure as code tool from HashiCorp. You describe cloud resources such as networks, databases and clusters in declarative configuration files. Terraform compares them with what exists, then creates, changes or deletes resources through provider plugins until the real system matches the files.

How it works

The core loop has three commands. terraform init downloads providers, terraform plan shows the proposed changes and terraform apply makes them. Terraform records what it manages in a state file and builds a dependency graph, so it creates resources in the right order and runs up to 10 operations in parallel by default.

For example, you add a versioning block to one S3 bucket and run a plan. It reports Plan: 0 to add, 1 to change, 0 to destroy. A reviewer reads that line in the pull request before anyone applies it.

Why it matters in production

The state file is the source of truth for what Terraform owns, so it needs a remote backend with locking. Two people applying at once can corrupt it. State can also hold secrets, so restrict access. Running plan on a schedule surfaces configuration drift from manual console edits.

See also

On the One2N blog

Further reading

Four-panel comic about Terraform: Console clicks: someone edits a security group by hand and nobody knows; Write the config; plan reads state, compares with the cloud, lists changes; Plan: 0 to add, 1 to change, 0 to destroy; reviewed in the pull request; apply; State lives in a remote locked...