Ad space (banner)
AD

Got the fundamentals? A structured Terraform course is a fast way to level up.

Find Terraform courses on Udemy

Affiliate link. Costs you nothing extra.

Lesson 7 / 37

What Is a Resource Block?

A resource block is how you declare a single piece of infrastructure — one server, one bucket, one database.

The form is resource "type" "name" { ... }, where the type identifies what to create and the name is your label for it within the configuration.

Writing resource "aws_instance" "web" { ... } declares an EC2 instance you refer to elsewhere as aws_instance.web — its address.

A common stumble is confusing the resource name with the resource's real name in the cloud. The label is internal to Terraform; the actual name comes from an attribute such as tags.

In real work, addresses like aws_instance.web are what you use in state show, in import, and when one resource references another.

Terraform
Try it (type this into the pseudo terminal)
terraform validate

🧑‍💻 You can type this command into the Terraform pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)