What is a Terraform Resource?
Answer
A Terraform Resource is the most important element in HCL — it represents a real infrastructure object to create and manage. Syntax: resource "<provider_type>" "<local_name>" { ... }. Example: resource "aws_instance" "web_server" { ami = "ami-0c55b159cbfafe1f0"; instance_type = "t3.micro"; tags = { Name = "WebServer" } }. The combination of type (aws_instance) and name (web_server) forms a unique address: aws_instance.web_server. Reference its attributes: aws_instance.web_server.id, aws_instance.web_server.public_ip. Terraform automatically orders resource creation based on references — if resource B references resource A's output, A is created first. Meta-arguments like count, for_each, depends_on, and lifecycle apply to all resource types.