DELAPARRA
Index
Color
NL
Category: Terraform

terraform block

Explained by Updated

What is terraform block?

terraform block: Settings for Terraform itself — required version, required providers, and the backend configuration. The terraform block configures Terraform itself rather than your infrastructure. It sets the required Terraform version, the providers you use with their versions, and where state is stored through the backend. Pinning versions here makes runs predictable. required_version = ">= 1.6" stops an older Terraform from running the code, and version constraints on providers stop surprise upgrades.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about terraform block

What should you keep in mind with terraform block?

The backend configuration cannot use variables, because it is read before anything else. Many teams pass backend settings at terraform init time with -backend-config options or a file, so the same code can use different state locations per environment. Keep this block at the top of a versions.tf or main.tf, so it is the first thing a new team member reads.

What does an example of terraform block look like?

terraform { required_version = ">= 1.6" required_providers { aws = { source = "hashicorp/aws", version = "~> 5.0" } } }

At a glance

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with T

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.