I have AWS ALB that using for multiple EC2 instances. In Terraform i have alb module which already created load balancer and listeners, target groups for that EC2 instances.
I want attach ec2 instance to target group . I did this in EC2 instance module which got ALB instace id from load balancer module outputs.
When i perform terraform apply command in ec2 instance module terraform wants to crete new ALB but its already created and using. Terraform state in ec2 module don't know about ALB but wants to perform code from this module to get outputs
How can i organize modules using common ALB for multiple EC2 instances without recreating ALB for every new EC2 instance?