Lesson 1 of 4 ยท Resource Relationships & Dependencies

References and attributes

A resource reference usually has three pieces: type, local name, and attribute. In aws_vpc.main.id, aws_vpc is the type, main is the local name, and id is the value Terraform reads from that resource.

Example

resource "aws_subnet" "public" {
  vpc_id = aws_vpc.main.id
}

Step by step

  1. Find the resource block first.
  2. Match its type and local name exactly.
  3. Use an attribute that the resource exposes.
  4. Let Terraform infer the order from the reference.

Common mistakes to avoid

  • Using the cloud display name instead of the Terraform local name.
  • Guessing an attribute without checking provider documentation.