What is interpolation?
Interpolation means using one resource’s attribute inside another resource. That is how you wire a subnet to a VPC, an instance to a security group, and so on.
Reference syntax
resource_type.local_name.attribute
Examples:
aws_instance.example.id
aws_instance.example.public_ip
aws_s3_bucket.demo.bucket
aws_vpc.main.idExample — subnet depends on VPC
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}aws_vpc.main.id tells Terraform: create the VPC first, then create the subnet with that VPC’s ID.
Dependency flow
VPC
↓
Subnet
↓
EC2 / Route table association / …
You do not need to declare depends_on for normal attribute references — Terraform builds the graph automatically from expressions like aws_vpc.main.id.
Prefer attribute references over depends_on. Use depends_on only for hidden side effects Terraform cannot see from expressions.