Error: Reference to undeclared resource

Hello, I’m getting the following error messages when I tried creating new AWS load balancer attachment and ALB target group attachment. What could be the problem?

Error: Reference to undeclared resource

  on autoscaling.tf line 25, in resource "aws_autoscaling_attachment" "autogrp-attach":
  25:   elb                    = aws_elb.test.id

A managed resource "aws_elb" "test" has not been declared in the root module.
Error: Reference to undeclared resource

  on autoscaling.tf line 30, in resource "aws_autoscaling_attachment" "alb-tg":
  30:   alb_target_group_arn   = aws_alb_target_group.smallgroup_tg.arn

A managed resource "aws_alb_target_group" "smallgroup_tg" has not been
declared in the root module.

Hi @adeg8825,

Unfortunately without seeing more of your configuration I don’t have anything to suggest except to ask something that might seem like a petulant question based on the error messages, but is honestly where I would start with debugging this…

Are there resource "aws_elb" "test" block and a resource "aws_alb_target_group" "smallgroup_tg" blocks in the root module?

1 Like

I think, It should be target_group_arn instead of alb_target_group_arn. Also double check your resource provider name and Copy/Paste resource provider to alb target group attachment resource.