Lesson 2 of 4 ยท Debugging Terraform
Fix incorrect references
A reference must match both the resource type and local name that Terraform declared. A subnet referencing aws_vpc.production cannot work if the configuration only declares aws_vpc.main.
Example
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
}Step by step
- Find the declaration.
- Copy the type and local name.
- Check the final attribute.
- Run validate again.
Common mistakes to avoid
- Using a similarly named resource from another example.
- Changing the attribute when the real problem is the local name.