Terraform resource
A resource block, which asks Terraform to create and manage one piece of infrastructure such as a network, file or database.
In more detail
It has two labels: the resource type, which comes from a provider, and a name you choose. Terraform records every resource it creates in state and from then on owns it, so it will update or delete it to match the configuration. To use something you do not own, read it with a data source instead.
Example
resource "local_file" "greeting" {
filename = "hello.txt"
content = "Hello from Terraform\n"
}Related terms
- resource type — The first label of a resource block, such as local_file or aws_vpc, naming the kind of thing to create.
- resource address — The type and name of a resource joined by a dot, such as local_file.greeting, which identifies it everywhere.
- data source — A data block that asks a provider to look up an existing object and return its details, without Terraform creating or owning it.
- Terraform state — Terraform's record, usually a JSON file called terraform.tfstate, mapping each resource in the configuration to the real object it created.
Taught in
- What Is Infrastructure As Code? — Infrastructure as Code with Terraform
- Installing Terraform And Meeting The CLI — Infrastructure as Code with Terraform
- Writing Your First Configuration In HCL — Infrastructure as Code with Terraform
- Querying Existing Infrastructure With Data Sources — Infrastructure as Code with Terraform
- Scaling Resources With Count — Infrastructure as Code with Terraform
- The Plan That Wanted To Destroy Production — HashiCorp Terraform Associate (004) Exam Prep
- One Hour, No Weights Published — HashiCorp Terraform Associate (004) Exam Prep
- Infrastructure As Code, And One Workflow For Every Platform — HashiCorp Terraform Associate (004) Exam Prep
- Providers: How Terraform Reaches Every API — HashiCorp Terraform Associate (004) Exam Prep
- Versions, The Lock File And Provider Aliases — HashiCorp Terraform Associate (004) Exam Prep
- State: Terraform's Memory Of What It Built — HashiCorp Terraform Associate (004) Exam Prep
- Write, Plan, Apply, And What Init Prepares — HashiCorp Terraform Associate (004) Exam Prep
- Reading A Plan, Saving It, Applying It — HashiCorp Terraform Associate (004) Exam Prep